Commit 3d5f848
committed
spotbugs(RCN+REC) ChatRequest source cleanup (4 cleared)
NullAway and the package's @NullMarked declaration prove the three
getters (ChatMessage.getContent, ToolCall.getArgumentsJson,
ToolDefinition.getDescription) are @nonnull at compile time, so the
runtime "value == null ? "" : value" ternaries and the
"if (getDescription() != null)" guard at three sites in
buildMessagesJson / buildToolsJson are dead.
Also narrows the catch in buildToolsJson from Exception to IOException.
The only checked exception MAPPER.readTree(String) can throw is
JsonProcessingException, which extends IOException — narrowing is
honest and removes the catch-Exception code smell.
Adds: import java.io.IOException.
Compatibility:
- Empty-string output on a null content/arguments is impossible per
NullAway, so removing the fallback never changes runtime behaviour.
- The 7 tests in ChatResponseTest (including
buildMessagesJsonRoundTripsToolTurns and
buildToolsJsonInlinesParameterSchema, which exercise both modified
code paths) stay green.
SpotBugs Max+Low:
- RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE: 4 -> 1
(ChatMessage.requireNonEmpty:103 remains, separate cluster)
- REC_CATCH_EXCEPTION: 1 -> 0
Total jllama: 19 -> 15.1 parent c6feef7 commit 3d5f848
1 file changed
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
170 | | - | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
183 | | - | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | | - | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | | - | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
0 commit comments