34
34
import reactor .core .Scannable ;
35
35
import reactor .core .publisher .Mono ;
36
36
import reactor .core .publisher .Operators ;
37
- import reactor .core .publisher .SignalType ;
38
37
import reactor .util .annotation .NonNull ;
39
38
import reactor .util .annotation .Nullable ;
40
39
@@ -69,8 +68,15 @@ final class FireAndForgetRequesterMono extends Mono<Void> implements Subscriptio
69
68
public void subscribe (CoreSubscriber <? super Void > actual ) {
70
69
long previousState = markSubscribed (STATE , this );
71
70
if (isSubscribedOrTerminated (previousState )) {
72
- Operators .error (
73
- actual , new IllegalStateException ("FireAndForgetMono allows only a single Subscriber" ));
71
+ final IllegalStateException e =
72
+ new IllegalStateException ("FireAndForgetMono allows only a single Subscriber" );
73
+
74
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
75
+ if (requestInterceptor != null ) {
76
+ requestInterceptor .onReject (e , FrameType .REQUEST_FNF , null );
77
+ }
78
+
79
+ Operators .error (actual , e );
74
80
return ;
75
81
}
76
82
@@ -81,14 +87,28 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
81
87
try {
82
88
if (!isValid (mtu , this .maxFrameLength , p , false )) {
83
89
lazyTerminate (STATE , this );
84
- p . release ();
85
- actual . onError (
90
+
91
+ final IllegalArgumentException e =
86
92
new IllegalArgumentException (
87
- String .format (INVALID_PAYLOAD_ERROR_MESSAGE , this .maxFrameLength )));
93
+ String .format (INVALID_PAYLOAD_ERROR_MESSAGE , this .maxFrameLength ));
94
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
95
+ if (requestInterceptor != null ) {
96
+ requestInterceptor .onReject (e , FrameType .REQUEST_FNF , p .metadata ());
97
+ }
98
+
99
+ p .release ();
100
+
101
+ actual .onError (e );
88
102
return ;
89
103
}
90
104
} catch (IllegalReferenceCountException e ) {
91
105
lazyTerminate (STATE , this );
106
+
107
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
108
+ if (requestInterceptor != null ) {
109
+ requestInterceptor .onReject (e , FrameType .REQUEST_FNF , null );
110
+ }
111
+
92
112
actual .onError (e );
93
113
return ;
94
114
}
@@ -98,22 +118,30 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
98
118
streamId = this .requesterResponderSupport .getNextStreamId ();
99
119
} catch (Throwable t ) {
100
120
lazyTerminate (STATE , this );
121
+
122
+ final Throwable ut = Exceptions .unwrap (t );
123
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
124
+ if (requestInterceptor != null ) {
125
+ requestInterceptor .onReject (ut , FrameType .REQUEST_FNF , p .metadata ());
126
+ }
127
+
101
128
p .release ();
102
- actual .onError (Exceptions .unwrap (t ));
129
+
130
+ actual .onError (ut );
103
131
return ;
104
132
}
105
133
106
134
final RequestInterceptor interceptor = this .requestInterceptor ;
107
135
if (interceptor != null ) {
108
- interceptor .onStart (streamId , FrameType .REQUEST_FNF , p .sliceMetadata ());
136
+ interceptor .onStart (streamId , FrameType .REQUEST_FNF , p .metadata ());
109
137
}
110
138
111
139
try {
112
140
if (isTerminated (this .state )) {
113
141
p .release ();
114
142
115
143
if (interceptor != null ) {
116
- interceptor .onEnd (streamId , SignalType . CANCEL );
144
+ interceptor .onCancel (streamId );
117
145
}
118
146
119
147
return ;
@@ -125,7 +153,7 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
125
153
lazyTerminate (STATE , this );
126
154
127
155
if (interceptor != null ) {
128
- interceptor .onEnd (streamId , SignalType . ON_ERROR );
156
+ interceptor .onTerminate (streamId , e );
129
157
}
130
158
131
159
actual .onError (e );
@@ -135,7 +163,7 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
135
163
lazyTerminate (STATE , this );
136
164
137
165
if (interceptor != null ) {
138
- interceptor .onEnd (streamId , SignalType . ON_COMPLETE );
166
+ interceptor .onTerminate (streamId , null );
139
167
}
140
168
141
169
actual .onComplete ();
@@ -162,19 +190,41 @@ public Void block(Duration m) {
162
190
public Void block () {
163
191
long previousState = markSubscribed (STATE , this );
164
192
if (isSubscribedOrTerminated (previousState )) {
165
- throw new IllegalStateException ("FireAndForgetMono allows only a single Subscriber" );
193
+ final IllegalStateException e =
194
+ new IllegalStateException ("FireAndForgetMono allows only a single Subscriber" );
195
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
196
+ if (requestInterceptor != null ) {
197
+ requestInterceptor .onReject (e , FrameType .REQUEST_FNF , null );
198
+ }
199
+ throw e ;
166
200
}
167
201
168
202
final Payload p = this .payload ;
169
203
try {
170
204
if (!isValid (this .mtu , this .maxFrameLength , p , false )) {
171
205
lazyTerminate (STATE , this );
206
+
207
+ final IllegalArgumentException e =
208
+ new IllegalArgumentException (
209
+ String .format (INVALID_PAYLOAD_ERROR_MESSAGE , this .maxFrameLength ));
210
+
211
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
212
+ if (requestInterceptor != null ) {
213
+ requestInterceptor .onReject (e , FrameType .REQUEST_FNF , p .metadata ());
214
+ }
215
+
172
216
p .release ();
173
- throw new IllegalArgumentException (
174
- String . format ( INVALID_PAYLOAD_ERROR_MESSAGE , this . maxFrameLength )) ;
217
+
218
+ throw e ;
175
219
}
176
220
} catch (IllegalReferenceCountException e ) {
177
221
lazyTerminate (STATE , this );
222
+
223
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
224
+ if (requestInterceptor != null ) {
225
+ requestInterceptor .onReject (e , FrameType .REQUEST_FNF , null );
226
+ }
227
+
178
228
throw Exceptions .propagate (e );
179
229
}
180
230
@@ -183,13 +233,20 @@ public Void block() {
183
233
streamId = this .requesterResponderSupport .getNextStreamId ();
184
234
} catch (Throwable t ) {
185
235
lazyTerminate (STATE , this );
236
+
237
+ final RequestInterceptor requestInterceptor = this .requestInterceptor ;
238
+ if (requestInterceptor != null ) {
239
+ requestInterceptor .onReject (Exceptions .unwrap (t ), FrameType .REQUEST_FNF , p .metadata ());
240
+ }
241
+
186
242
p .release ();
243
+
187
244
throw Exceptions .propagate (t );
188
245
}
189
246
190
247
final RequestInterceptor interceptor = this .requestInterceptor ;
191
248
if (interceptor != null ) {
192
- interceptor .onStart (streamId , FrameType .REQUEST_FNF , p .sliceMetadata ());
249
+ interceptor .onStart (streamId , FrameType .REQUEST_FNF , p .metadata ());
193
250
}
194
251
195
252
try {
@@ -205,7 +262,7 @@ public Void block() {
205
262
lazyTerminate (STATE , this );
206
263
207
264
if (interceptor != null ) {
208
- interceptor .onEnd (streamId , SignalType . ON_ERROR );
265
+ interceptor .onTerminate (streamId , e );
209
266
}
210
267
211
268
throw Exceptions .propagate (e );
@@ -214,7 +271,7 @@ public Void block() {
214
271
lazyTerminate (STATE , this );
215
272
216
273
if (interceptor != null ) {
217
- interceptor .onEnd (streamId , SignalType . ON_COMPLETE );
274
+ interceptor .onTerminate (streamId , null );
218
275
}
219
276
220
277
return null ;
0 commit comments