@@ -83,6 +83,16 @@ public void close() {
83
83
this .rrClient = null ;
84
84
}
85
85
86
+ private ShadowUpdatedEvent createShadowUpdatedEvent (IncomingPublishEvent publishEvent ) {
87
+ String payload = new String (publishEvent .getPayload (), StandardCharsets .UTF_8 );
88
+ return this .gson .fromJson (payload , ShadowUpdatedEvent .class );
89
+ }
90
+
91
+ private ShadowDeltaUpdatedEvent createShadowDeltaUpdatedEvent (IncomingPublishEvent publishEvent ) {
92
+ String payload = new String (publishEvent .getPayload (), StandardCharsets .UTF_8 );
93
+ return this .gson .fromJson (payload , ShadowDeltaUpdatedEvent .class );
94
+ }
95
+
86
96
/**
87
97
* Deletes a named shadow for an AWS IoT thing.
88
98
*
@@ -504,8 +514,7 @@ public StreamingOperation createNamedShadowDeltaUpdatedStream(NamedShadowDeltaUp
504
514
.withSubscriptionStatusEventCallback (options .subscriptionEventHandler ())
505
515
.withIncomingPublishEventCallback ((event ) -> {
506
516
try {
507
- String payload = new String (event .getPayload (), StandardCharsets .UTF_8 );
508
- ShadowDeltaUpdatedEvent response = this .gson .fromJson (payload , ShadowDeltaUpdatedEvent .class );
517
+ ShadowDeltaUpdatedEvent response = createShadowDeltaUpdatedEvent (event );
509
518
options .streamEventHandler ().accept (response );
510
519
} catch (Exception e ) {
511
520
V2DeserializationFailureEvent failureEvent = V2DeserializationFailureEvent .builder ()
@@ -551,8 +560,7 @@ public StreamingOperation createNamedShadowUpdatedStream(NamedShadowUpdatedSubsc
551
560
.withSubscriptionStatusEventCallback (options .subscriptionEventHandler ())
552
561
.withIncomingPublishEventCallback ((event ) -> {
553
562
try {
554
- String payload = new String (event .getPayload (), StandardCharsets .UTF_8 );
555
- ShadowUpdatedEvent response = this .gson .fromJson (payload , ShadowUpdatedEvent .class );
563
+ ShadowUpdatedEvent response = createShadowUpdatedEvent (event );
556
564
options .streamEventHandler ().accept (response );
557
565
} catch (Exception e ) {
558
566
V2DeserializationFailureEvent failureEvent = V2DeserializationFailureEvent .builder ()
@@ -593,8 +601,7 @@ public StreamingOperation createShadowDeltaUpdatedStream(ShadowDeltaUpdatedSubsc
593
601
.withSubscriptionStatusEventCallback (options .subscriptionEventHandler ())
594
602
.withIncomingPublishEventCallback ((event ) -> {
595
603
try {
596
- String payload = new String (event .getPayload (), StandardCharsets .UTF_8 );
597
- ShadowDeltaUpdatedEvent response = this .gson .fromJson (payload , ShadowDeltaUpdatedEvent .class );
604
+ ShadowDeltaUpdatedEvent response = createShadowDeltaUpdatedEvent (event );
598
605
options .streamEventHandler ().accept (response );
599
606
} catch (Exception e ) {
600
607
V2DeserializationFailureEvent failureEvent = V2DeserializationFailureEvent .builder ()
@@ -635,8 +642,7 @@ public StreamingOperation createShadowUpdatedStream(ShadowUpdatedSubscriptionReq
635
642
.withSubscriptionStatusEventCallback (options .subscriptionEventHandler ())
636
643
.withIncomingPublishEventCallback ((event ) -> {
637
644
try {
638
- String payload = new String (event .getPayload (), StandardCharsets .UTF_8 );
639
- ShadowUpdatedEvent response = this .gson .fromJson (payload , ShadowUpdatedEvent .class );
645
+ ShadowUpdatedEvent response = createShadowUpdatedEvent (event );
640
646
options .streamEventHandler ().accept (response );
641
647
} catch (Exception e ) {
642
648
V2DeserializationFailureEvent failureEvent = V2DeserializationFailureEvent .builder ()
0 commit comments