From 04e12f875ab633538d0b0fb0f16bb6081f5a5d5a Mon Sep 17 00:00:00 2001 From: pankajjangid05 Date: Mon, 15 May 2023 16:11:59 +0530 Subject: [PATCH] [Bug Fix] - Creating Unmarshaller Object Every Time Because It is not thread safe --- src/main/java/messagerosa/xml/XMessageParser.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/messagerosa/xml/XMessageParser.java b/src/main/java/messagerosa/xml/XMessageParser.java index 20bbf01..53435e2 100644 --- a/src/main/java/messagerosa/xml/XMessageParser.java +++ b/src/main/java/messagerosa/xml/XMessageParser.java @@ -21,18 +21,16 @@ public class XMessageParser { public static JAXBContext context; - public static Unmarshaller jaxbUnmarshaller; - static { try { context = JAXBContext.newInstance(XMessage.class); - jaxbUnmarshaller = context.createUnmarshaller(); } catch (JAXBException e) { e.printStackTrace(); } } public static XMessage parse(InputStream stream) throws JAXBException { + Unmarshaller jaxbUnmarshaller = context.createUnmarshaller(); return (XMessage) jaxbUnmarshaller.unmarshal(stream); } }