Commit 6bc3ab31 by Nilu

fix index out of bounds for email fetcher

parent 4831b0f0
...@@ -481,12 +481,12 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -481,12 +481,12 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
private static String getFirstName(String name) private static String getFirstName(String name)
{ {
return (name.split("\\w+").length > 1) ? name.substring(0, name.lastIndexOf(' ')) : name; return ((name.split("\\w+").length > 1) && (name.lastIndexOf(' ') > 0 )) ? name.substring(0, name.lastIndexOf(' ')) : name;
} }
private static String getLastName(String name) private static String getLastName(String name)
{ {
return (name.split("\\w+").length > 1) ? name.substring(name.lastIndexOf(" ")+1) : ""; return ((name.split("\\w+").length > 1) && (name.lastIndexOf(' ') > 0 )) ? name.substring(name.lastIndexOf(" ")+1) : "";
} }
public static String getJobIdentifierFromEmail(String strReceipient) public static String getJobIdentifierFromEmail(String strReceipient)
...@@ -509,7 +509,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -509,7 +509,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
{ {
BodyPart bodyPart = multipart.getBodyPart(j); BodyPart bodyPart = multipart.getBodyPart(j);
if(Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition())) if(Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()) && bodyPart.getFileName() != null && !bodyPart.getFileName().isEmpty())
{ {
bytes = IOUtils.readInputStreamToBytes(bodyPart.getInputStream()); bytes = IOUtils.readInputStreamToBytes(bodyPart.getInputStream());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment