Skip to content

Commit

Permalink
Prevent NumberFormatException for blank input string
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Mar 26, 2024
1 parent c5bc6a8 commit 84180f2
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;

public class MapMessageObjectReader {

Expand Down Expand Up @@ -129,8 +130,8 @@ public String getMandatoryString(String key) throws JMSException {
public Collection<Integer> getCollectionOfInteger(String key) throws JMSException {
Collection<String> collectionOfString = getCollectionOfString(key);
List<Integer> collectionOfInteger = collectionOfString.stream()
.flatMap(string -> Arrays.stream(string.split("\\D+"))).map(Integer::valueOf)
.collect(Collectors.toList());
.flatMap(string -> Arrays.stream(string.split("\\D+"))).filter(Strings::isNotBlank)
.map(Integer::valueOf).collect(Collectors.toList());
return collectionOfInteger;
}

Expand Down

0 comments on commit 84180f2

Please sign in to comment.