Skip to content

Commit

Permalink
[KYUUBI apache#5961][FOLLOWUP] Prevent NPE when checking ticket cache…
Browse files Browse the repository at this point in the history
… exists

# 🔍 Description
Followup apache#5961

```
scala> Files.exists(Paths.get(null))
<console>:14: error: ambiguous reference to overloaded definition,
both method get in class Paths of type (x$1: java.net.URI)java.nio.file.Path
and  method get in class Paths of type (x$1: String, x$2: String*)java.nio.file.Path
match argument types (Null) and expected result type java.nio.file.Path
       Files.exists(Paths.get(null))
                          ^

scala> Files.exists(Paths.get(""))
res0: Boolean = true

scala>

```
## Issue References 🔗

This pull request fixes #

## Describe Your Solution 🔧

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

## Types of changes :bookmark:

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request :coffin:

#### Behavior With This Pull Request :tada:

#### Related Unit Tests

---

# Checklist 📝

- [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes apache#5980 from turboFei/fix_npe.

Closes apache#5961

99d4a16 [Fei Wang] fix npe

Authored-by: Fei Wang <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
  • Loading branch information
turboFei authored and zhaohehuhu committed Mar 21, 2024
1 parent 631ba5e commit 34820ae
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ private static Configuration createLoginFromTgtCacheConfiguration(String ticketC
if (StringUtils.isBlank(ticketCache)) {
ticketCache = System.getenv("KRB5CCNAME");
}
if (!Files.exists(Paths.get(ticketCache))) {
LOG.warn("TicketCache {} does not exist", ticketCache);
}
if (StringUtils.isNotBlank(ticketCache)) {
if (!Files.exists(Paths.get(ticketCache))) {
LOG.warn("TicketCache {} does not exist", ticketCache);
}
optionsBuilder.put("ticketCache", ticketCache);
}
return createConfiguration(optionsBuilder);
Expand Down

0 comments on commit 34820ae

Please sign in to comment.