@@ -62,7 +62,7 @@ public void reset() {
62
62
@ Override
63
63
public void translateText (
64
64
TranslateTextRequest request , StreamObserver <TranslateTextResponse > responseObserver ) {
65
- Object response = responses .remove ();
65
+ Object response = responses .poll ();
66
66
if (response instanceof TranslateTextResponse ) {
67
67
requests .add (request );
68
68
responseObserver .onNext (((TranslateTextResponse ) response ));
@@ -74,7 +74,7 @@ public void translateText(
74
74
new IllegalArgumentException (
75
75
String .format (
76
76
"Unrecognized response type %s for method TranslateText, expected %s or %s" ,
77
- response .getClass ().getName (),
77
+ response == null ? "null" : response .getClass ().getName (),
78
78
TranslateTextResponse .class .getName (),
79
79
Exception .class .getName ())));
80
80
}
@@ -83,7 +83,7 @@ public void translateText(
83
83
@ Override
84
84
public void detectLanguage (
85
85
DetectLanguageRequest request , StreamObserver <DetectLanguageResponse > responseObserver ) {
86
- Object response = responses .remove ();
86
+ Object response = responses .poll ();
87
87
if (response instanceof DetectLanguageResponse ) {
88
88
requests .add (request );
89
89
responseObserver .onNext (((DetectLanguageResponse ) response ));
@@ -95,7 +95,7 @@ public void detectLanguage(
95
95
new IllegalArgumentException (
96
96
String .format (
97
97
"Unrecognized response type %s for method DetectLanguage, expected %s or %s" ,
98
- response .getClass ().getName (),
98
+ response == null ? "null" : response .getClass ().getName (),
99
99
DetectLanguageResponse .class .getName (),
100
100
Exception .class .getName ())));
101
101
}
@@ -104,7 +104,7 @@ public void detectLanguage(
104
104
@ Override
105
105
public void getSupportedLanguages (
106
106
GetSupportedLanguagesRequest request , StreamObserver <SupportedLanguages > responseObserver ) {
107
- Object response = responses .remove ();
107
+ Object response = responses .poll ();
108
108
if (response instanceof SupportedLanguages ) {
109
109
requests .add (request );
110
110
responseObserver .onNext (((SupportedLanguages ) response ));
@@ -116,7 +116,7 @@ public void getSupportedLanguages(
116
116
new IllegalArgumentException (
117
117
String .format (
118
118
"Unrecognized response type %s for method GetSupportedLanguages, expected %s or %s" ,
119
- response .getClass ().getName (),
119
+ response == null ? "null" : response .getClass ().getName (),
120
120
SupportedLanguages .class .getName (),
121
121
Exception .class .getName ())));
122
122
}
@@ -125,7 +125,7 @@ public void getSupportedLanguages(
125
125
@ Override
126
126
public void batchTranslateText (
127
127
BatchTranslateTextRequest request , StreamObserver <Operation > responseObserver ) {
128
- Object response = responses .remove ();
128
+ Object response = responses .poll ();
129
129
if (response instanceof Operation ) {
130
130
requests .add (request );
131
131
responseObserver .onNext (((Operation ) response ));
@@ -137,7 +137,7 @@ public void batchTranslateText(
137
137
new IllegalArgumentException (
138
138
String .format (
139
139
"Unrecognized response type %s for method BatchTranslateText, expected %s or %s" ,
140
- response .getClass ().getName (),
140
+ response == null ? "null" : response .getClass ().getName (),
141
141
Operation .class .getName (),
142
142
Exception .class .getName ())));
143
143
}
@@ -146,7 +146,7 @@ public void batchTranslateText(
146
146
@ Override
147
147
public void createGlossary (
148
148
CreateGlossaryRequest request , StreamObserver <Operation > responseObserver ) {
149
- Object response = responses .remove ();
149
+ Object response = responses .poll ();
150
150
if (response instanceof Operation ) {
151
151
requests .add (request );
152
152
responseObserver .onNext (((Operation ) response ));
@@ -158,7 +158,7 @@ public void createGlossary(
158
158
new IllegalArgumentException (
159
159
String .format (
160
160
"Unrecognized response type %s for method CreateGlossary, expected %s or %s" ,
161
- response .getClass ().getName (),
161
+ response == null ? "null" : response .getClass ().getName (),
162
162
Operation .class .getName (),
163
163
Exception .class .getName ())));
164
164
}
@@ -167,7 +167,7 @@ public void createGlossary(
167
167
@ Override
168
168
public void listGlossaries (
169
169
ListGlossariesRequest request , StreamObserver <ListGlossariesResponse > responseObserver ) {
170
- Object response = responses .remove ();
170
+ Object response = responses .poll ();
171
171
if (response instanceof ListGlossariesResponse ) {
172
172
requests .add (request );
173
173
responseObserver .onNext (((ListGlossariesResponse ) response ));
@@ -179,15 +179,15 @@ public void listGlossaries(
179
179
new IllegalArgumentException (
180
180
String .format (
181
181
"Unrecognized response type %s for method ListGlossaries, expected %s or %s" ,
182
- response .getClass ().getName (),
182
+ response == null ? "null" : response .getClass ().getName (),
183
183
ListGlossariesResponse .class .getName (),
184
184
Exception .class .getName ())));
185
185
}
186
186
}
187
187
188
188
@ Override
189
189
public void getGlossary (GetGlossaryRequest request , StreamObserver <Glossary > responseObserver ) {
190
- Object response = responses .remove ();
190
+ Object response = responses .poll ();
191
191
if (response instanceof Glossary ) {
192
192
requests .add (request );
193
193
responseObserver .onNext (((Glossary ) response ));
@@ -199,7 +199,7 @@ public void getGlossary(GetGlossaryRequest request, StreamObserver<Glossary> res
199
199
new IllegalArgumentException (
200
200
String .format (
201
201
"Unrecognized response type %s for method GetGlossary, expected %s or %s" ,
202
- response .getClass ().getName (),
202
+ response == null ? "null" : response .getClass ().getName (),
203
203
Glossary .class .getName (),
204
204
Exception .class .getName ())));
205
205
}
@@ -208,7 +208,7 @@ public void getGlossary(GetGlossaryRequest request, StreamObserver<Glossary> res
208
208
@ Override
209
209
public void deleteGlossary (
210
210
DeleteGlossaryRequest request , StreamObserver <Operation > responseObserver ) {
211
- Object response = responses .remove ();
211
+ Object response = responses .poll ();
212
212
if (response instanceof Operation ) {
213
213
requests .add (request );
214
214
responseObserver .onNext (((Operation ) response ));
@@ -220,7 +220,7 @@ public void deleteGlossary(
220
220
new IllegalArgumentException (
221
221
String .format (
222
222
"Unrecognized response type %s for method DeleteGlossary, expected %s or %s" ,
223
- response .getClass ().getName (),
223
+ response == null ? "null" : response .getClass ().getName (),
224
224
Operation .class .getName (),
225
225
Exception .class .getName ())));
226
226
}
0 commit comments