@@ -443,19 +443,17 @@ private void error(SocketIOException e) {
443
443
* @param text
444
444
* the Text to be send.
445
445
*/
446
- private void sendPlain (String text ) {
447
- synchronized (outputBuffer ) {
448
- if (getState () == STATE_READY )
449
- try {
450
- logger .info ("> " + text );
451
- transport .send (text );
452
- } catch (Exception e ) {
453
- logger .info ("IOEx: saving" );
454
- outputBuffer .add (text );
455
- }
456
- else {
446
+ private synchronized void sendPlain (String text ) {
447
+ if (getState () == STATE_READY )
448
+ try {
449
+ logger .info ("> " + text );
450
+ transport .send (text );
451
+ } catch (Exception e ) {
452
+ logger .info ("IOEx: saving" );
457
453
outputBuffer .add (text );
458
454
}
455
+ else {
456
+ outputBuffer .add (text );
459
457
}
460
458
}
461
459
@@ -505,38 +503,36 @@ private IOCallback findCallback(IOMessage message) throws SocketIOException {
505
503
*
506
504
* {@link IOTransport} calls this when a connection is established.
507
505
*/
508
- public void transportConnected () {
506
+ public synchronized void transportConnected () {
509
507
setState (STATE_READY );
510
508
if (reconnectTask != null ) {
511
509
reconnectTask .cancel ();
512
510
reconnectTask = null ;
513
511
}
514
512
resetTimeout ();
515
- synchronized (outputBuffer ) {
516
- if (transport .canSendBulk ()) {
517
- ConcurrentLinkedQueue <String > outputBuffer = this .outputBuffer ;
518
- this .outputBuffer = new ConcurrentLinkedQueue <String >();
519
- try {
520
- // DEBUG
521
- String [] texts = outputBuffer
522
- .toArray (new String [outputBuffer .size ()]);
523
- logger .info ("Bulk start:" );
524
- for (String text : texts ) {
525
- logger .info ("> " + text );
526
- }
527
- logger .info ("Bulk end" );
528
- // DEBUG END
529
- transport .sendBulk (texts );
530
- } catch (IOException e ) {
531
- this .outputBuffer = outputBuffer ;
513
+ if (transport .canSendBulk ()) {
514
+ ConcurrentLinkedQueue <String > outputBuffer = this .outputBuffer ;
515
+ this .outputBuffer = new ConcurrentLinkedQueue <String >();
516
+ try {
517
+ // DEBUG
518
+ String [] texts = outputBuffer .toArray (new String [outputBuffer
519
+ .size ()]);
520
+ logger .info ("Bulk start:" );
521
+ for (String text : texts ) {
522
+ logger .info ("> " + text );
532
523
}
533
- } else {
534
- String text ;
535
- while ((text = outputBuffer .poll ()) != null )
536
- sendPlain (text );
524
+ logger .info ("Bulk end" );
525
+ // DEBUG END
526
+ transport .sendBulk (texts );
527
+ } catch (IOException e ) {
528
+ this .outputBuffer = outputBuffer ;
537
529
}
538
- this .keepAliveInQueue = false ;
530
+ } else {
531
+ String text ;
532
+ while ((text = outputBuffer .poll ()) != null )
533
+ sendPlain (text );
539
534
}
535
+ this .keepAliveInQueue = false ;
540
536
}
541
537
542
538
/**
0 commit comments