Skip to content

Commit

Permalink
[ISSUE apache#3472]Do some code optimization[HttpProtocolAdaptor] (ap…
Browse files Browse the repository at this point in the history
…ache#3883)

* Update HttpProtocolAdaptor.java

1. 
imported `java.util.Collections`
returns `Collections.emptyList()` at line 81.

2. Used `Objects.requireNonNull()` at line 103

* Update HttpProtocolAdaptor.java
  • Loading branch information
harshithasudhakar authored Nov 12, 2023
1 parent a60d46f commit 9cb1704
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.eventmesh.protocol.http.resolver.HttpRequestProtocolResolver;

import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -77,7 +78,7 @@ private CloudEvent deserializeProtocol(String requestURI, HttpEventWrapper httpE
@Override
public List<CloudEvent> toBatchCloudEvent(ProtocolTransportObject protocol)
throws ProtocolHandleException {
return null;
return Collections.emptyList();
}

@Override
Expand All @@ -98,7 +99,7 @@ public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws Prot
// ce data
if (null != cloudEvent.getData()) {
Map<String, Object> dataContentMap = JsonUtils.parseTypeReferenceObject(
new String(cloudEvent.getData().toBytes(), Constants.DEFAULT_CHARSET),
new String(Objects.requireNonNull(cloudEvent.getData()).toBytes(), Constants.DEFAULT_CHARSET),
new TypeReference<Map<String, Object>>() {
});
String requestHeader = JsonUtils.toJSONString(
Expand Down

0 comments on commit 9cb1704

Please sign in to comment.