Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid this escape, and minor code clean up #32261

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author hmusum
*/
public class AppSubDirs {
public final class AppSubDirs {

private final Tuple2<File, String> root;
private final Tuple2<File, String> routingtables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
import com.yahoo.collections.Tuple2;
import com.yahoo.vespa.config.util.ConfigUtils;

import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Objects;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Logger;
Expand All @@ -30,7 +38,7 @@ public class Bundle {
public Bundle(JarFile jarFile, File bundleFile) {
this.jarFile = jarFile;
this.bundleFile = bundleFile;
defEntries = findDefEntries();
defEntries = List.copyOf(findDefEntries());
}

public static List<Bundle> getBundles(File bundleDir) {
Expand All @@ -56,11 +64,11 @@ private static List<File> getBundleFiles(File bundleDir) {
if (!bundleDir.isDirectory()) {
return new ArrayList<>();
}
return List.of(bundleDir.listFiles((dir, name) -> name.endsWith(".jar")));
return List.of(Objects.requireNonNull(bundleDir.listFiles((dir, name) -> name.endsWith(".jar"))));
}

public List<DefEntry> getDefEntries() {
return Collections.unmodifiableList(defEntries);
return defEntries;
}

/**
Expand Down Expand Up @@ -93,18 +101,14 @@ private List<DefEntry> findDefEntries() {
return defEntries;
}

public JarFile getJarFile() {
return jarFile;
}

public File getFile() {
return bundleFile;
}

/**
* Represents a def-file inside a Component. Immutable.
*/
public static class DefEntry {
public static final class DefEntry {

private final Bundle bundle;
private final ZipEntry zipEntry;
Expand Down Expand Up @@ -139,7 +143,7 @@ private String getNamespace() {
}

private String getContents() {
StringBuilder ret = new StringBuilder("");
StringBuilder ret = new StringBuilder();
BufferedReader reader = new BufferedReader(getReader());
try {
String str = reader.readLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
/**
* @author mortent
*/
public class FeedClientBuilder extends FeedClientBuilderImpl {
public final class FeedClientBuilder extends FeedClientBuilderImpl {

static AtomicReference<EndpointAuthenticator> endpointAuthenticator = new AtomicReference<>();
private static final AtomicReference<EndpointAuthenticator> endpointAuthenticator = new AtomicReference<>();

public static void setEndpointAuthenticator(EndpointAuthenticator authenticator) {
endpointAuthenticator.set(authenticator);
Expand Down