Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions clients/src/main/java/org/apache/kafka/common/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -901,25 +901,6 @@ public FileVisitResult postVisitDirectory(Path path, IOException exc) throws IOE
});
}

/**
* Returns an empty list if the provided list is null, otherwise returns the list itself.
* <p>
* This method is useful for avoiding {@code NullPointerException} when working with potentially null lists.
*
* @param other the list to check for null
* @return an empty list if the provided list is null, otherwise the original list
*/
public static <T> List<T> safe(List<T> other) {
return other == null ? Collections.emptyList() : other;
}

/**
* Get the ClassLoader which loaded Kafka.
*/
public static ClassLoader getKafkaClassLoader() {
return Utils.class.getClassLoader();
}

/**
* Get the Context ClassLoader on this thread or, if not present, the ClassLoader that
* loaded Kafka.
Expand All @@ -929,7 +910,7 @@ public static ClassLoader getKafkaClassLoader() {
public static ClassLoader getContextOrKafkaClassLoader() {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null)
return getKafkaClassLoader();
return Utils.class.getClassLoader();
else
return cl;
}
Expand Down