Skip to content

Commit

Permalink
[Issue #382] Fix java.lang.NumberFormatException when parsing Long (#383
Browse files Browse the repository at this point in the history
)

* [Issue #337] Fix HttpSubscriber startup issue

* [Issue #337] test commit

* [Issue #337] revert test commit

* [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

* [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

* [Issue #337] Address code review comment for Subscriber Demo App

* [Issue #368] Fix Racing condition and memory leak issue in EventMesh SDK LiteConsumer and LiteProducer

* [Issue #368] fix build issue

* [Issue #368] use try with resource statement for HttpClient

* [Issue #368] fix TLS1.1 and use TLS1.2 in HttpClient

* [Issue #382] Fix java.lang.NumberFormatException when parsing Long

* [Issue #382] Fix java.lang.NumberFormatException when parsing Integer

Co-authored-by: j00441484 <[email protected]>
  • Loading branch information
jinrongluo and j00441484 authored Jun 9, 2021
1 parent 0fdbd04 commit cfcb2a7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@

import io.openmessaging.api.Message;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.api.AbstractContext;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer;
import org.apache.eventmesh.runtime.constants.EventMeshConstants;
import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf;
import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf;
import org.slf4j.Logger;
Expand Down Expand Up @@ -79,7 +81,8 @@ public HandleMsgContext(String msgRandomNo, String consumerGroup, EventMeshConsu
this.bizSeqNo = bizSeqNo;
this.uniqueId = uniqueId;
this.consumeTopicConfig = consumeTopicConfig;
this.ttl = Integer.parseInt(msg.getUserProperties(Constants.PROPERTY_MESSAGE_TIMEOUT));
String ttlStr = msg.getUserProperties(Constants.PROPERTY_MESSAGE_TIMEOUT);
this.ttl = StringUtils.isNumeric(ttlStr)? Integer.parseInt(ttlStr): EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS;
}

public void addProp(String key, String val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext<HttpCommand>
return;
}

eventMeshHTTPServer.metrics.summaryMetrics.recordSendBatchMsg(Integer.parseInt(sendMessageBatchRequestBody.getSize()));
String sizeStr = sendMessageBatchRequestBody.getSize();
long delta = StringUtils.isNumeric(sizeStr)? Integer.parseInt(sizeStr) : 0;
eventMeshHTTPServer.metrics.summaryMetrics.recordSendBatchMsg(delta);

if (eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerBatchMsgBatchEnabled) {
for (List<Message> batchMsgs : topicBatchMessageMappings.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.openmessaging.api.Message;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.api.AbstractContext;
import org.apache.eventmesh.common.Constants;
Expand Down Expand Up @@ -53,7 +54,9 @@ public ClientAckContext(String seq, AbstractContext context, List<Message> msgs,
this.msgs = msgs;
this.consumer = consumer;
this.createTime = System.currentTimeMillis();
this.expireTime = System.currentTimeMillis() + Long.parseLong(msgs.get(0).getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL));
String ttlStr = msgs.get(0).getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL);
long ttl = StringUtils.isNumeric(ttlStr)? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS;
this.expireTime = System.currentTimeMillis() + ttl;
}

public boolean isExpire() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import io.openmessaging.api.Message;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.api.AbstractContext;
import org.apache.eventmesh.common.Constants;
Expand Down Expand Up @@ -70,7 +71,9 @@ public DownStreamMsgContext(Message msgExt, Session session, MQConsumerWrapper c
this.lastPushTime = System.currentTimeMillis();
this.executeTime = System.currentTimeMillis();
this.createTime = System.currentTimeMillis();
this.expireTime = System.currentTimeMillis() + Long.parseLong(msgExt.getUserProperties("TTL"));
String ttlStr = msgExt.getUserProperties("TTL");
long ttl = StringUtils.isNumeric(ttlStr) ? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS;
this.expireTime = System.currentTimeMillis() + ttl;
this.msgFromOtherEventMesh = msgFromOtherEventMesh;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ private void retryHandle(DownStreamMsgContext downStreamMsgContext) {

private boolean isRetryMsgTimeout(DownStreamMsgContext downStreamMsgContext) {
boolean flag = false;
long ttl = Long.parseLong(downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL));
//TODO 关注是否能取到
long storeTimestamp = Long.parseLong(downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.STORE_TIME));
String ttlStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL);
long ttl = StringUtils.isNumeric(ttlStr)? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS;;

String storeTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.STORE_TIME);
long storeTimestamp = StringUtils.isNumeric(storeTimeStr)? Long.parseLong(storeTimeStr) : 0;
String leaveTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.LEAVE_TIME);
long brokerCost = StringUtils.isNumeric(leaveTimeStr) ? Long.parseLong(leaveTimeStr) - storeTimestamp : 0;

Expand Down

0 comments on commit cfcb2a7

Please sign in to comment.