Stirling-PDF/src/main/java/stirling/software/SPDF
pixeebot[bot] 3afacf2405
Switch order of literals to prevent NullPointerException (#2769)
This change defensively switches the order of literals in comparison
expressions to ensure that no null pointer exceptions are unexpectedly
thrown. Runtime exceptions especially can cause exceptional and
unexpected code paths to be taken, and this can result in unexpected
behavior.

Both simple vulnerabilities (like information disclosure) and complex
vulnerabilities (like business logic flaws) can take advantage of these
unexpected code paths.

Our changes look something like this:

```diff
  String fieldName = header.getFieldName();
  String fieldValue = header.getFieldValue();
- if(fieldName.equals("requestId")) {
+ if("requestId".equals(fieldName)) {
    logRequest(fieldValue);
  }
```

<details>
  <summary>More reading</summary>

*
[https://cwe.mitre.org/data/definitions/476.html](https://cwe.mitre.org/data/definitions/476.html)
*
[https://en.wikibooks.org/wiki/Java_Programming/Preventing_NullPointerException](https://en.wikibooks.org/wiki/Java_Programming/Preventing_NullPointerException)
*
[https://rules.sonarsource.com/java/RSPEC-1132/](https://rules.sonarsource.com/java/RSPEC-1132/)
</details>

🧚🤖  Powered by Pixeebot  

[Feedback](https://ask.pixee.ai/feedback) |
[Community](https://pixee-community.slack.com/signup#/domain-signup) |
[Docs](https://docs.pixee.ai/) | Codemod ID:
pixee:java/switch-literal-first
![](https://d1zaessa2hpsmj.cloudfront.net/pixel/v1/track?writeKey=2PI43jNm7atYvAuK7rJUz3Kcd6A&event=DRIP_PR%7CStirling-Tools%2FStirling-PDF%7Cc45a84d1797c774f11f1a6a0ccbbd8ee5a208be3)


<!--{"type":"DRIP","codemod":"pixee:java/switch-literal-first"}-->

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
2025-01-22 10:39:47 +00:00
..
config Pdf to markdown (#2730) 2025-01-17 22:18:55 +00:00
controller Pdf to markdown (#2730) 2025-01-17 22:18:55 +00:00
EE #2418 updating jpackage config (#2713) 2025-01-17 12:25:02 +00:00
Factories commit for feature developing invert-replace color of a pdf for stirl… (#1982) 2024-10-04 16:53:00 +01:00
model Pdf to markdown (#2730) 2025-01-17 22:18:55 +00:00
pdf formattingand autowired constructors (#2557) 2024-12-24 09:52:53 +00:00
repository formattingand autowired constructors (#2557) 2024-12-24 09:52:53 +00:00
service Switch order of literals to prevent NullPointerException (#2769) 2025-01-22 10:39:47 +00:00
UI File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00
utils Pdf to markdown (#2730) 2025-01-17 22:18:55 +00:00
LibreOfficeListener.java formattingand autowired constructors (#2557) 2024-12-24 09:52:53 +00:00
SPDFApplication.java #2270: External DB Support (#2457) 2025-01-06 18:58:26 +00:00