@@ -105,7 +105,8 @@ public void finished(Thread t) {
105105
106106 private void terminate (String message , Exception e ) {
107107 // write log
108- StringBuilder sb = this .startLog ();
108+ StringBuilder sb = new StringBuilder ();
109+ sb .append (this .getLogStart ());
109110 sb .append (message );
110111 if (e != null ) {
111112 sb .append (e .getLocalizedMessage ());
@@ -122,7 +123,8 @@ private void sendOnlineMessages() throws IOException {
122123 this .onlineMessageSources = new ArrayList <>();
123124 while (!copy .isEmpty ()) {
124125 ASAPOnlineMessageSource asapOnline = copy .remove (0 );
125- StringBuilder sb = this .startLog ();
126+ StringBuilder sb = new StringBuilder ();
127+ sb .append (this .getLogStart ());
126128 sb .append ("going to send online message" );
127129 System .out .println (sb .toString ());
128130 asapOnline .sendMessages (this , this .os );
@@ -134,9 +136,9 @@ private class OnlineMessageSenderThread extends Thread {
134136 public void run () {
135137 try {
136138 // get exclusive access to streams
137- System .out .println (startLog () + "online sender is going to wait for stream access" );
139+ System .out .println (getLogStart () + "online sender is going to wait for stream access" );
138140 wait4ExclusiveStreamsAccess ();
139- System .out .println (startLog () + "online sender got stream access" );
141+ System .out .println (getLogStart () + "online sender got stream access" );
140142 sendOnlineMessages ();
141143 // prepare a graceful death
142144 onlineMessageSenderThread = null ;
@@ -146,7 +148,7 @@ public void run() {
146148 terminate ("could not write data into stream" , e );
147149 }
148150 finally {
149- System .out .println (startLog () + "online sender releases lock" );
151+ System .out .println (getLogStart () + "online sender releases lock" );
150152 releaseStreamsLock ();
151153 }
152154 }
@@ -201,10 +203,10 @@ public void run() {
201203 while (!this .terminated ) {
202204 this .pduReader = new ASAPPDUReader (protocol , is , this );
203205 try {
204- System .out .println (this .startLog () + "start reading" );
206+ System .out .println (this .getLogStart () + "start reading" );
205207 this .runObservedThread (pduReader , this .maxExecutionTime );
206208 } catch (ASAPExecTimeExceededException e ) {
207- System .out .println (this .startLog () + "reading on stream took longer than allowed" );
209+ System .out .println (this .getLogStart () + "reading on stream took longer than allowed" );
208210 }
209211
210212 System .out .println (this .getLogStart () + "back from reading" );
@@ -236,19 +238,19 @@ public void run() {
236238 protocol ,this );
237239
238240 // get exclusive access to streams
239- System .out .println (this .startLog () + "asap pdu executor going to wait for stream access" );
241+ System .out .println (this .getLogStart () + "asap pdu executor going to wait for stream access" );
240242 this .wait4ExclusiveStreamsAccess ();
241243 try {
242- System .out .println (this .startLog () + "asap pdu executor got stream access - process pdu" );
244+ System .out .println (this .getLogStart () + "asap pdu executor got stream access - process pdu" );
243245 this .runObservedThread (executor , maxExecutionTime );
244246 } catch (ASAPExecTimeExceededException e ) {
245- System .out .println (this .startLog () + "asap pdu processing took longer than allowed" );
247+ System .out .println (this .getLogStart () + "asap pdu processing took longer than allowed" );
246248 this .terminate ("asap pdu processing took longer than allowed" , e );
247249 break ;
248250 } finally {
249251 // wake waiting thread if any
250252 this .releaseStreamsLock ();
251- System .out .println (this .startLog () + "asap pdu executor release locks" );
253+ System .out .println (this .getLogStart () + "asap pdu executor release locks" );
252254 }
253255 } catch (ASAPException e ) {
254256 System .out .println (this .getLogStart () + " problem when executing asap received pdu: " + e );
@@ -327,15 +329,6 @@ private void runObservedThread(Thread t, long maxExecutionTime) throws ASAPExecT
327329 throw new ASAPExecTimeExceededException (sb .toString ());
328330 }
329331
330- private StringBuilder startLog () {
331- StringBuilder sb = net .sharksystem .asap .util .Log .startLog (this );
332- sb .append (" recipient: " );
333- sb .append (this .remotePeer );
334- sb .append (" | " );
335-
336- return sb ;
337- }
338-
339332 private class ASAPPDUExecutor extends Thread {
340333 private final ASAP_PDU_1_0 asapPDU ;
341334 private final InputStream is ;
@@ -355,6 +348,7 @@ public ASAPPDUExecutor(ASAP_PDU_1_0 asapPDU, InputStream is, OutputStream os,
355348 this .threadFinishedListener = threadFinishedListener ;
356349
357350 StringBuilder sb = new StringBuilder ();
351+ sb .append (getLogStart ());
358352 sb .append ("ASAPPDUExecutor created - " );
359353 sb .append ("folder: " + engineSetting .folder + " | " );
360354 sb .append ("engine: " + engineSetting .engine .getClass ().getSimpleName () + " | " );
@@ -373,25 +367,26 @@ private void finish() {
373367
374368 public void run () {
375369 if (engineSetting .engine == null ) {
376- System .err .println ("ASAPPDUExecutor called without engine set - fatal" );
370+ System .err .println (getLogStart () + "ASAPPDUExecutor called without engine set - fatal" );
377371 this .finish ();
378372 return ;
379373 }
380374
381- System .out .println ("ASAPPDUExecutor calls engine: " + engineSetting .engine .getClass ().getSimpleName ());
375+ System .out .println (getLogStart () + "ASAPPDUExecutor calls engine: "
376+ + engineSetting .engine .getClass ().getSimpleName ());
382377
383378 try {
384379 switch (asapPDU .getCommand ()) {
385380 case ASAP_1_0 .INTEREST_CMD :
386- System .out .println ("ASAPPDUExecutor call handleASAPInterest" );
381+ System .out .println (getLogStart () + "ASAPPDUExecutor call handleASAPInterest" );
387382 engineSetting .engine .handleASAPInterest ((ASAP_Interest_PDU_1_0 ) asapPDU , protocol , os );
388383 break ;
389384 case ASAP_1_0 .OFFER_CMD :
390- System .out .println ("ASAPPDUExecutor call handleASAPOffer" );
385+ System .out .println (getLogStart () + "ASAPPDUExecutor call handleASAPOffer" );
391386 engineSetting .engine .handleASAPOffer ((ASAP_OfferPDU_1_0 ) asapPDU , protocol , os );
392387 break ;
393388 case ASAP_1_0 .ASSIMILATE_CMD :
394- System .out .println ("ASAPPDUExecutor call handleASAPAssimilate" );
389+ System .out .println ("getLogStart() + ASAPPDUExecutor call handleASAPAssimilate" );
395390 engineSetting .engine .handleASAPAssimilate ((ASAP_AssimilationPDU_1_0 ) asapPDU , protocol , is , os ,
396391 engineSetting .listener );
397392 break ;
@@ -445,7 +440,6 @@ ASAP_PDU_1_0 getASAPPDU() {
445440 public void run () {
446441 try {
447442 this .asapPDU = protocol .readPDU (is );
448- // this.pduReaderListener.finished(this);
449443 } catch (IOException e ) {
450444 this .ioException = e ;
451445 } catch (ASAPException e ) {
0 commit comments