before_code stringlengths 30 149k | reviewer_comment stringlengths 16 20.6k | after_code stringlengths 30 163k | diff_context stringlengths 0 22.4k | file_path stringlengths 6 155 | comment_line int64 0 26 | language stringclasses 19
values | quality_score float64 0.07 1 | comment_type stringclasses 9
values | comment_length int64 16 20.6k | before_lines int64 2 4.61k | after_lines int64 2 4.4k | is_negative bool 2
classes | pr_title stringlengths 7 140 | pr_number int64 18 61.2k | repo_name stringclasses 29
values | repo_stars int64 321 56k | repo_language stringclasses 14
values | reviewer_username stringclasses 378
values | author_username stringclasses 739
values | user stringlengths 361 200k | assistant stringlengths 16 20.6k | system stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
"The input JAR ("
+ jarPath
+ ") is compiled with Java "
+ jarJavaVersion
+ ", but the default base image only supports versions up to Java 11. Specify a custom base image with --from.");
}
String jarType = determineJarType(jarPath);
if (jar... | I wasn't sure who should empty the directory, e.g., if `StandardExplodedProcessor` should clear it instead of `JarProcessors`. I think either makes sense, but if we want the caller to clear it, we should check the precondition inside `StandardExplodedProcessor` to verify that the directory does not exist or is empty.
... | + jarJavaVersion
+ ", but the default base image only supports versions up to Java 11. Specify a custom base image with --from.");
}
String jarType = determineJarType(jarPath);
if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.packaged)) {
return new SpringBoot... | @@ -59,11 +61,22 @@ public static JarProcessor from(
if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.packaged)) {
return new SpringBootPackagedProcessor(jarPath);
} else if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.exploded)) {
- return new SpringBootExplodedProcesso... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java | 26 | Java | 0.643 | suggestion | 383 | 51 | 51 | false | Modify jib cli jar command to preserve source file path | 3,035 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
PR Title: Modify jib cli jar command to preserve source file path
BEFORE CODE: "The input JAR ("
+ jarPath
+ ") is compiled with Java "
... | I wasn't sure who should empty the directory, e.g., if `StandardExplodedProcessor` should clear it instead of `JarProcessors`. I think either makes sense, but if we want the caller to clear it, we should check the precondition inside `StandardExplodedProcessor` to verify that the directory does not exist or is empty.
... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
defaultValue = "Docker",
paramLabel = "<image-format>",
description =
"Format of container, candidates: ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE}.")
@SuppressWarnings("NullAway.Init") // initialized by picocli
private ImageFormat format;
@CommandLine.Option(
names = "-... | Another option is to provide the default (e.g., 0?). That way, maybe `creationTime` can never be null?
Either way has pros and cons though. | defaultValue = "Docker",
paramLabel = "<image-format>",
description =
"Format of container, candidates: ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE}.")
@SuppressWarnings("NullAway.Init") // initialized by picocli
private ImageFormat format;
@CommandLine.Option(
names = "-... | @@ -150,6 +151,14 @@
"Entrypoint for container. Overrides the default entrypoint, example: --entrypoint='custom entrypoint'")
private List<String> entrypoint = Collections.emptyList();
+ @CommandLine.Option(
+ names = "--creation-time",
+ paramLabel = "<creation-time>",
+ description = | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java | 26 | Java | 0.643 | suggestion | 142 | 51 | 51 | false | [jib-cli-jar] Add option to specify creation time of container | 3,050 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
PR Title: [jib-cli-jar] Add option to specify creation time of container
BEFORE CODE: defaultValue = "Docker",
paramLabel = "<image-format>",
description =
"Format of conta... | Another option is to provide the default (e.g., 0?). That way, maybe `creationTime` can never be null?
Either way has pros and cons though. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
project.setArtifactId("artifact");
Properties projectProperties = project.getProperties();
projectProperties.setProperty("jib.containerize", "group:artifact");
Assert.assertTrue(testPluginConfiguration.isContainerizable());
projectProperties.setProperty("jib.containerize", "group:artifact2");
... | tdp --> tempDirectoryProvider
and it must be closed.
```suggestion
try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) {
``` | /*
* Copyright 2018 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | @@ -342,4 +350,12 @@ public void testIsContainerizable_directory() {
projectProperties.setProperty("jib.containerize", "project2");
Assert.assertFalse(testPluginConfiguration.isContainerizable());
}
+
+ @Test
+ public void testGetMavenProjectProperties() {
+ TempDirectoryProvider tdp = new TempDirecto... | jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/JibPluginConfigurationTest.java | 26 | Java | 0.714 | suggestion | 164 | 32 | 347 | false | Support for getting / injecting shared Maven components in JibMavenPluginExtension | 3,062 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | stefanocke | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/JibPluginConfigurationTest.java
PR Title: Support for getting / injecting shared Maven components in JibMavenPluginExtension
BEFORE CODE: project.setArtifactId("artifact");
Properties proje... | tdp --> tempDirectoryProvider
and it must be closed.
```suggestion
try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) {
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Arrays.asList(new FooExtensionConfig()), containerBuilder);
Assert.assertEquals("user from extension", extendedBuilder.toContainerBuildPlan().getUser());
mavenProjectProperties.waitForLoggingThread();
Mockito.verify(mockLog).error("awesome error from my extension");
Mockito.verify(mockLog)
... | ```diff
FooExtension loadedExtension =
new FooExtension(
(buildPlan, properties, extraConfig, mavenData, logger) -> {
- return buildPlan.toBuilder().setUser("user from extension").build();
+ return buildPlan.toBuilder().setBaseImage("my base image").build();
... | Arrays.asList(new FooExtensionConfig()), containerBuilder);
Assert.assertEquals("user from extension", extendedBuilder.toContainerBuildPlan().getUser());
mavenProjectProperties.waitForLoggingThread();
Mockito.verify(mockLog).error("awesome error from my extension");
Mockito.verify(mockLog)
... | @@ -450,4 +451,76 @@ public void testRunPluginExtensions_runtimeExceptionFromExtension() {
Assert.assertEquals("extension crashed: buggy extension", ex.getMessage());
}
}
+
+ @Test
+ public void testRunPluginExtensions_injected() throws JibPluginExtensionException {
+ FooExtension injectedExtension ... | jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesExtensionTest.java | 26 | Java | 1 | suggestion | 604 | 51 | 51 | false | Support for getting / injecting shared Maven components in JibMavenPluginExtension | 3,062 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | stefanocke | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesExtensionTest.java
PR Title: Support for getting / injecting shared Maven components in JibMavenPluginExtension
BEFORE CODE: Arrays.asList(new FooExtensionConfig())... | ```diff
FooExtension loadedExtension =
new FooExtension(
(buildPlan, properties, extraConfig, mavenData, logger) -> {
- return buildPlan.toBuilder().setUser("user from extension").build();
+ return buildPlan.toBuilder().setBaseImage("my base image").build();
... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// this parameter is cloned in FilesMojo
@Parameter private ExtraDirectoriesParameters extraDirectories = new ExtraDirectoriesParameters();
@Parameter private DockerClientParameters dockerClient = new DockerClientParameters();
@Parameter private OutputPathsParameters outputPaths = new OutputPathsParameters()... | `JibPluginConfiguration` is mainly for describing the Jib configuration for Maven (and some Maven stuff). I don't want to make this tightly coupled with ~~`JibMavenPluginExtension` and~~ `MavenProjectProperties`. Can we just move this to `MavenProjectProperties` or somewhere more suitable? I am fine duplicating these i... | // this parameter is cloned in FilesMojo
@Parameter private ExtraDirectoriesParameters extraDirectories = new ExtraDirectoriesParameters();
@Parameter private DockerClientParameters dockerClient = new DockerClientParameters();
@Parameter private OutputPathsParameters outputPaths = new OutputPathsParameters();... | @@ -346,6 +349,12 @@ public String getExtensionClass() {
@Component protected SettingsDecrypter settingsDecrypter;
+ @Inject private Set<JibMavenPluginExtension<?>> injectedPluginExtensions = Collections.emptySet();
+
+ protected Set<JibMavenPluginExtension<?>> getInjectedPluginExtensions() {
+ return injec... | jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java | 26 | Java | 0.643 | refactor | 359 | 51 | 51 | false | Support for getting / injecting shared Maven components in JibMavenPluginExtension | 3,062 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | stefanocke | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java
PR Title: Support for getting / injecting shared Maven components in JibMavenPluginExtension
BEFORE CODE:
// this parameter is cloned in FilesMojo
@Parameter private... | `JibPluginConfiguration` is mainly for describing the Jib configuration for Maven (and some Maven stuff). I don't want to make this tightly coupled with ~~`JibMavenPluginExtension` and~~ `MavenProjectProperties`. Can we just move this to `MavenProjectProperties` or somewhere more suitable? I am fine duplicating these i... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
SettingsDecrypter getSettingsDecrypter() {
return settingsDecrypter;
}
@VisibleForTesting
void setProject(MavenProject project) {
this.project = project;
}
@VisibleForTesting
void setSession(MavenSession session) {
this.session = session;
}
@VisibleForTesting
void setDescriptor(Plugi... | As I said above, I don't want this class to know about `MavenProjectProperties`. | /*
* Copyright 2018 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | @@ -821,8 +830,24 @@ void setSession(MavenSession session) {
this.session = session;
}
+ @VisibleForTesting
+ void setDescriptor(PluginDescriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+
@Nullable
String getProperty(String propertyName) {
return MavenProjectProperties.getProperty(p... | jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java | 26 | Java | 0.357 | suggestion | 80 | 37 | 837 | false | Support for getting / injecting shared Maven components in JibMavenPluginExtension | 3,062 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | stefanocke | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java
PR Title: Support for getting / injecting shared Maven components in JibMavenPluginExtension
BEFORE CODE:
SettingsDecrypter getSettingsDecrypter() {
return setting... | As I said above, I don't want this class to know about `MavenProjectProperties`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
*/
private static String determineJarType(Path jarPath) throws IOException {
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
if (jarFile.getEntry("BOOT-INF") != null) {
return SPRING_BOOT;
}
return STANDARD;
}
}
/**
* Determines the java version of JAR. Derives the... | Unrelated, we need to close the loader below.
```java
try (URLClassLoader loader = new URLClassLoader(new URL[] {jarPath.toUri().toURL()});
DataInputStream classFile =
new DataInputStream(loader.getResourceAsStream(jarEntry))) {
``` | * @param jarPath path to the jar
* @return the jar type
* @throws IOException if I/O error occurs when opening the file
*/
private static String determineJarType(Path jarPath) throws IOException {
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
if (jarFile.getEntry("BOOT-INF") != null) {... | @@ -90,8 +89,7 @@ private static String determineJarType(Path jarPath) throws IOException {
* @return java version
* @throws IOException if I/O exception thrown when opening the jar file
*/
- @VisibleForTesting
- static Integer getJavaMajorVersion(Path jarPath) throws IOException {
+ public static Intege... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java | 26 | Java | 0.786 | suggestion | 279 | 47 | 51 | false | Use AdoptOpenJDK image as default base image in Jib CLI Jar | 3,075 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
PR Title: Use AdoptOpenJDK image as default base image in Jib CLI Jar
BEFORE CODE: */
private static String determineJarType(Path jarPath) throws IOException {
try (JarFile jarF... | Unrelated, we need to close the loader below.
```java
try (URLClassLoader loader = new URLClassLoader(new URL[] {jarPath.toUri().toURL()});
DataInputStream classFile =
new DataInputStream(loader.getResourceAsStream(jarEntry))) {
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
CliLogger.newLogger(
commonCliOptions.getVerbosity(),
commonCliOptions.getConsoleOutput(),
spec.commandLine().getOut(),
spec.commandLine().getErr(),
executor);
if (!Files.exists(jarFile)) {
logger.log(LogEvent.Level.ERROR, "T... | Instead of making `getJavaMajorVersion()` public and calling it twice (although I have no idea if there will be noticeable performance impact when "opening a jar" twice with `new JarFile()` in this case), how about adding a field `JarProcessor.javaVersion` and a getter for it? (Maybe the current `getJavaMajorVersion()`... | CliLogger.newLogger(
commonCliOptions.getVerbosity(),
commonCliOptions.getConsoleOutput(),
spec.commandLine().getOut(),
spec.commandLine().getErr(),
executor);
if (!Files.exists(jarFile)) {
logger.log(LogEvent.Level.ERROR, "T... | @@ -198,8 +198,9 @@ public Integer call() {
CacheDirectories cacheDirectories =
CacheDirectories.from(commonCliOptions, jarFile.toAbsolutePath().getParent());
JarProcessor processor = JarProcessors.from(jarFile, cacheDirectories, mode);
+ Integer jarJavaVersion = JarProcessors.getJavaMajor... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java | 26 | Java | 0.786 | performance | 551 | 51 | 51 | false | Use AdoptOpenJDK image as default base image in Jib CLI Jar | 3,075 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
PR Title: Use AdoptOpenJDK image as default base image in Jib CLI Jar
BEFORE CODE: CliLogger.newLogger(
commonCliOptions.getVerbosity(),
commonCliOptions.getConso... | Instead of making `getJavaMajorVersion()` public and calling it twice (although I have no idea if there will be noticeable performance impact when "opening a jar" twice with `new JarFile()` in this case), how about adding a field `JarProcessor.javaVersion` and a getter for it? (Maybe the current `getJavaMajorVersion()`... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/*
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | Looks like the access can be limited to the package.
```suggestion
class SpringBootPackagedProcessor implements JarProcessor {
``` | /*
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | @@ -25,9 +25,17 @@
public class SpringBootPackagedProcessor implements JarProcessor { | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootPackagedProcessor.java | 25 | Java | 0.714 | suggestion | 135 | 50 | 50 | false | Use AdoptOpenJDK image as default base image in Jib CLI Jar | 3,075 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootPackagedProcessor.java
PR Title: Use AdoptOpenJDK image as default base image in Jib CLI Jar
BEFORE CODE: /*
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (th... | Looks like the access can be limited to the package.
```suggestion
class SpringBootPackagedProcessor implements JarProcessor {
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.tools.jib.cli.jar;
import com.google.cl... | ```suggestion
SpringBootPackagedProcessor(Path jarPath, Integer jarJavaVersion) {
``` | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.tools.jib.cli.jar;
import com.google.cl... | @@ -25,9 +25,17 @@
public class SpringBootPackagedProcessor implements JarProcessor {
private final Path jarPath;
+ private final Integer jarJavaVersion;
- public SpringBootPackagedProcessor(Path jarPath) {
+ /**
+ * Constructor for {@link SpringBootPackagedProcessor}.
+ *
+ * @param jarPath path to ja... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootPackagedProcessor.java | 26 | Java | 0.571 | suggestion | 89 | 51 | 51 | false | Use AdoptOpenJDK image as default base image in Jib CLI Jar | 3,075 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/SpringBootPackagedProcessor.java
PR Title: Use AdoptOpenJDK image as default base image in Jib CLI Jar
BEFORE CODE: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIE... | ```suggestion
SpringBootPackagedProcessor(Path jarPath, Integer jarJavaVersion) {
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@Test
public void testLog() {
ImmutableMap.Builder<Level, Consumer<String>> messageConsumers = ImmutableMap.builder();
for (Level level : Level.values()) {
messageConsumers.put(level, createMessageConsumer(level));
}
testPlainConsoleLogger =
new PlainConsoleLogger(messageConsumers.bu... | Ah let's add a new test `testLog_filterOutColors()` for this instead of changing the existing test. |
@Test
public void testLog() {
ImmutableMap.Builder<Level, Consumer<String>> messageConsumers = ImmutableMap.builder();
for (Level level : Level.values()) {
messageConsumers.put(level, createMessageConsumer(level));
}
testPlainConsoleLogger =
new PlainConsoleLogger(messageConsumers.bu... | @@ -63,7 +63,7 @@ public void testLog() {
Level.LIFECYCLE, Level.PROGRESS, Level.INFO, Level.DEBUG, Level.WARN, Level.ERROR),
levels);
Assert.assertEquals(
- Arrays.asList("lifecycle", "progress", "info", "debug", "warn", "error"), messages);
+ Arrays.asList("lifecycle", " progr... | jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/logging/PlainConsoleLoggerTest.java | 26 | Java | 0.429 | suggestion | 99 | 51 | 51 | false | Disable coloring in build output when `--console=plain` is used | 3,087 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | vinod-tahelyani | Review this pull request change.
Language: Java
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/logging/PlainConsoleLoggerTest.java
PR Title: Disable coloring in build output when `--console=plain` is used
BEFORE CODE:
@Test
public void testLog() {
ImmutableMap.Builder<Leve... | Ah let's add a new test `testLog_filterOutColors()` for this instead of changing the existing test. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import org.junit.Test;
/** Tests for {@link PlainConsoleLogger}. */
public class PlainConsoleLoggerTest {
private static final Duration SHUTDOWN_TIMEOUT = Duration.ofSeconds(3);
private final SingleThreadedExecutor singleThreadedExecutor = new SingleThreadedExecutor();
private final List<Level> levels = new A... | perhaps we can remove the spaces here and below:
```suggestion
testPlainConsoleLogger.log(Level.PROGRESS, "\u001B[33mprogress\u001B[0m");
``` | import org.junit.Test;
/** Tests for {@link PlainConsoleLogger}. */
public class PlainConsoleLoggerTest {
private static final Duration SHUTDOWN_TIMEOUT = Duration.ofSeconds(3);
private final SingleThreadedExecutor singleThreadedExecutor = new SingleThreadedExecutor();
private final List<Level> levels = new A... | @@ -49,12 +49,12 @@ public void testLog() {
testPlainConsoleLogger =
new PlainConsoleLogger(messageConsumers.build(), singleThreadedExecutor);
- testPlainConsoleLogger.log(Level.LIFECYCLE, "lifecycle");
- testPlainConsoleLogger.log(Level.PROGRESS, "progress");
+ testPlainConsoleLogger.log(Level... | jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/logging/PlainConsoleLoggerTest.java | 26 | Java | 0.786 | suggestion | 149 | 51 | 51 | false | Disable coloring in build output when `--console=plain` is used | 3,087 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | vinod-tahelyani | Review this pull request change.
Language: Java
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/logging/PlainConsoleLoggerTest.java
PR Title: Disable coloring in build output when `--console=plain` is used
BEFORE CODE: import org.junit.Test;
/** Tests for {@link PlainConsoleLogger}... | perhaps we can remove the spaces here and below:
```suggestion
testPlainConsoleLogger.log(Level.PROGRESS, "\u001B[33mprogress\u001B[0m");
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Assert.assertEquals(
Arrays.asList("lifecycle", "progress", "info", "debug", "warn", "error"), messages);
}
@Test
public void testLog_filterOutColors() {
ImmutableMap.Builder<Level, Consumer<String>> messageConsumers = ImmutableMap.builder();
for (Level level : Level.values()) {
message... | just need to fix a few formatting issues here | Assert.assertEquals(
Arrays.asList("lifecycle", "progress", "info", "debug", "warn", "error"), messages);
}
@Test
public void testLog_filterOutColors() {
ImmutableMap.Builder<Level, Consumer<String>> messageConsumers = ImmutableMap.builder();
for (Level level : Level.values()) {
message... | @@ -63,7 +63,31 @@ public void testLog() {
Level.LIFECYCLE, Level.PROGRESS, Level.INFO, Level.DEBUG, Level.WARN, Level.ERROR),
levels);
Assert.assertEquals(
- Arrays.asList("lifecycle", " progress", "info", "debug", "warn", " error "), messages);
+ Arrays.asList("lifecycle", "pr... | jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/logging/PlainConsoleLoggerTest.java | 26 | Java | 0.071 | style | 45 | 51 | 51 | false | Disable coloring in build output when `--console=plain` is used | 3,087 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | vinod-tahelyani | Review this pull request change.
Language: Java
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/logging/PlainConsoleLoggerTest.java
PR Title: Disable coloring in build output when `--console=plain` is used
BEFORE CODE: Assert.assertEquals(
Arrays.asList("lifecycle", "pro... | just need to fix a few formatting issues here | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@VisibleForTesting
static Integer determineJavaMajorVersion(Path jarPath) throws IOException {
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
Enumeration<JarEntry> jarEntries = jarFile.entries();
while (jarEntries.hasMoreElements()) {
String jarEntry = jarEntries.nextElement().toStr... | Testing with a jar file containing a fake empty .class file resulted in an EOFException with no error message. This change is to provide more clarity on why this exception is being thrown. | */
@VisibleForTesting
static Integer determineJavaMajorVersion(Path jarPath) throws IOException {
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
Enumeration<JarEntry> jarEntries = jarFile.entries();
while (jarEntries.hasMoreElements()) {
String jarEntry = jarEntries.nextElement()... | @@ -116,6 +118,11 @@ static Integer determineJavaMajorVersion(Path jarPath) throws IOException {
int majorVersion = classFile.readUnsignedShort();
int javaVersion = (majorVersion - 45) + 1;
return javaVersion;
+ } catch (EOFException ex) {
+ throw new IllegalAr... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java | 26 | Java | 0.571 | suggestion | 190 | 30 | 37 | false | [jib-cli-jar] Add clearer error message for when the class file format is invalid. | 3,095 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
PR Title: [jib-cli-jar] Add clearer error message for when the class file format is invalid.
BEFORE CODE: @VisibleForTesting
static Integer determineJavaMajorVersion(Path jarPath) t... | Testing with a jar file containing a fake empty .class file resulted in an EOFException with no error message. This change is to provide more clarity on why this exception is being thrown. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@SuppressWarnings("NullAway.Init") // initialized by picocli
CommonCliOptions commonCliOptions;
@CommandLine.Parameters(description = "The path to the jar file (ex: path/to/my-jar.jar)")
@SuppressWarnings("NullAway.Init") // initialized by picocli
private Path jarFile;
@CommandLine.Option(
names = "... | Isn't this only for textual message in the help text? Previously, I thought showing
```
--jvm-flags <jvm-flags> JVM arguments, ...
```
made sense, because you'll provide a list of flags. Why should it be in a singular form? | @SuppressWarnings("NullAway.Init") // initialized by picocli
CommonCliOptions commonCliOptions;
@CommandLine.Parameters(description = "The path to the jar file (ex: path/to/my-jar.jar)")
@SuppressWarnings("NullAway.Init") // initialized by picocli
private Path jarFile;
@CommandLine.Option(
names = "... | @@ -80,37 +80,37 @@
@CommandLine.Option(
names = "--jvm-flags",
- paramLabel = "<jvm-flags>",
+ paramLabel = "<jvm-flag>", | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java | 26 | Java | 0.857 | question | 227 | 51 | 51 | false | Fix typos in usage text for Jar command | 3,103 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Jar.java
PR Title: Fix typos in usage text for Jar command
BEFORE CODE: @SuppressWarnings("NullAway.Init") // initialized by picocli
CommonCliOptions commonCliOptions;
@CommandLine.Parameters(descriptio... | Isn't this only for textual message in the help text? Previously, I thought showing
```
--jvm-flags <jvm-flags> JVM arguments, ...
```
made sense, because you'll provide a list of flags. Why should it be in a singular form? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@Test
public void testCreateContainerBuilder_noErrorIfWebInfLibDoesNotExist()
throws IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
temporaryFolder.newFolder("WEB-INF", "classes");
setUpWarProject(temporaryFolder.getRoot().toPath());
setupBuildContext(); // should ... | This test wasn't even testing if the extraction paths start with `DEFAULT_WEB_APP_ROOT`. The test is identical to the one right above. | gradleProjectProperties.createJibContainerBuilder(
JavaContainerBuilder.from("ignored"), ContainerizingMode.EXPLODED))
.isNotNull();
}
@Test
public void testCreateContainerBuilder_noErrorIfWebInfLibDoesNotExist()
throws IOException, InvalidImageReferenceException {
t... | @@ -420,63 +390,27 @@ public void testCreateContainerBuilder_war()
"/my/app/WEB-INF/classes/package/Other.class");
}
- @Test
- public void testCreateContainerBuilder_defaultWebAppRoot()
- throws URISyntaxException, IOException, InvalidImageReferenceException, | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java | 26 | Java | 0.571 | refactor | 135 | 51 | 51 | false | Remove out-of-scope tests in `GradleProjectProperties` | 3,112 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java
PR Title: Remove out-of-scope tests in `GradleProjectProperties`
BEFORE CODE:
@Test
public void testCreateContainerBuilder_noErrorIfWebInfLibDoesNotExist()
... | This test wasn't even testing if the extraction paths start with `DEFAULT_WEB_APP_ROOT`. The test is identical to the one right above. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
convention.setTargetCompatibility(JavaVersion.VERSION_1_3);
assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(3);
convention.setTargetCompatibility(JavaVersion.VERSION_11);
assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(11);
convention.setTargetCompatibility(... | ```suggestion
public void testCreateContainerBuilder_correctSourceFiles()
``` | convention.setTargetCompatibility(JavaVersion.VERSION_1_3);
assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(3);
convention.setTargetCompatibility(JavaVersion.VERSION_11);
assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(11);
convention.setTargetCompatibility(... | @@ -238,8 +238,7 @@ public void testGetMajorJavaVersion_jvm11() {
@Test
public void testCreateContainerBuilder_correctFiles() | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java | 26 | Java | 0.571 | suggestion | 81 | 51 | 51 | false | Remove out-of-scope tests in `GradleProjectProperties` | 3,112 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java
PR Title: Remove out-of-scope tests in `GradleProjectProperties`
BEFORE CODE: convention.setTargetCompatibility(JavaVersion.VERSION_1_3);
assertThat(gradle... | ```suggestion
public void testCreateContainerBuilder_correctSourceFiles()
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@Test
public void testCreateContainerBuilder_noClassesFiles()
throws InvalidImageReferenceException, IOException {
Project project =
ProjectBuilder.builder()
.withProjectDir(temporaryFolder.newFolder())
.withGradleUserHomeDir(temporaryFolder.newFolder())
.build(... | ```suggestion
public void testCreateContainerBuilder_correctExtractionPaths()
``` | @Test
public void testCreateContainerBuilder_noClassesFiles()
throws InvalidImageReferenceException, IOException {
Project project =
ProjectBuilder.builder()
.withProjectDir(temporaryFolder.newFolder())
.withGradleUserHomeDir(temporaryFolder.newFolder())
.build(... | @@ -302,10 +301,9 @@ public void testCreateContainerBuilder_noClassesFiles()
}
@Test
- public void testCreateContainerBuilder_nonDefaultAppRoot()
+ public void testCreateContainerBuilder_extractionPaths() | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java | 26 | Java | 0.643 | refactor | 85 | 51 | 51 | false | Remove out-of-scope tests in `GradleProjectProperties` | 3,112 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java
PR Title: Remove out-of-scope tests in `GradleProjectProperties`
BEFORE CODE: @Test
public void testCreateContainerBuilder_noClassesFiles()
throws Invali... | ```suggestion
public void testCreateContainerBuilder_correctExtractionPaths()
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.containsExactly(
"/my/app/META-INF",
"/my/app/META-INF/context.xml",
"/my/app/Test.jsp",
"/my/app/WEB-INF",
"/my/app/WEB-INF/classes",
"/my/app/WEB-INF/classes/empty_dir",
"/my/app/WEB-INF/classes/package",
"/my/app... | Ah sorry, missed this earlier. The behavior seems a little vague here. Adding a few tests on what the layers might look like (for example) might help? | .containsExactly(
"/my/app/META-INF",
"/my/app/META-INF/context.xml",
"/my/app/Test.jsp",
"/my/app/WEB-INF",
"/my/app/WEB-INF/classes",
"/my/app/WEB-INF/classes/empty_dir",
"/my/app/WEB-INF/classes/package",
"/my/app... | @@ -420,63 +390,27 @@ public void testCreateContainerBuilder_war()
"/my/app/WEB-INF/classes/package/Other.class");
}
- @Test
- public void testCreateContainerBuilder_defaultWebAppRoot()
- throws URISyntaxException, IOException, InvalidImageReferenceException,
- CacheDirectoryCreationEx... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java | 26 | Java | 0.357 | question | 150 | 51 | 51 | false | Remove out-of-scope tests in `GradleProjectProperties` | 3,112 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleProjectPropertiesTest.java
PR Title: Remove out-of-scope tests in `GradleProjectProperties`
BEFORE CODE: .containsExactly(
"/my/app/META-INF",
"/my/app/META-I... | Ah sorry, missed this earlier. The behavior seems a little vague here. Adding a few tests on what the layers might look like (for example) might help? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
createProject("java", "war", "org.springframework.boot", "com.google.cloud.tools.jib");
TaskContainer tasks = project.getTasks();
// should depend on bootWar even if disabled
tasks.named("bootWar").configure(task -> task.setEnabled(false));
Task warTask = tasks.getByPath(":war");
Task bootW... | does this work?
```suggestion
assertThat(jar.getArchiveClassifier().get()).isEmpty()
``` | createProject("java", "war", "org.springframework.boot", "com.google.cloud.tools.jib");
TaskContainer tasks = project.getTasks();
// should depend on bootWar even if disabled
tasks.named("bootWar").configure(task -> task.setEnabled(false));
Task warTask = tasks.getByPath(":war");
Task bootW... | @@ -218,8 +201,8 @@ public void testSpringBootJarProject_nonPackagedMode() {
createProject("java", "org.springframework.boot", "com.google.cloud.tools.jib");
Jar jar = (Jar) project.getTasks().getByPath(":jar");
- Assert.assertFalse(jar.getEnabled());
- Assert.assertEquals("", jar.getArchiveClassi... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibPluginTest.java | 26 | Java | 0.571 | question | 95 | 51 | 51 | false | Migrate to Truth and remove warning suppressions | 3,120 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibPluginTest.java
PR Title: Migrate to Truth and remove warning suppressions
BEFORE CODE: createProject("java", "war", "org.springframework.boot", "com.google.cloud.tools.jib");
TaskC... | does this work?
```suggestion
assertThat(jar.getArchiveClassifier().get()).isEmpty()
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
System.setProperty("jib.dockerClient.environment", "env1=val1,env2=val2");
assertThat(testJibExtension.getDockerClient().getEnvironment())
.containsExactly("env1", "val1", "env2", "val2")
.inOrder();
// Absolute paths
System.setProperty("jib.outputPaths.digest", "/digest/path");
ass... | Since `runtimeClasspath` is the default, how about this?
```suggestion
System.setProperty("jib.configurationName", "myConfiguration");
``` | System.setProperty("jib.dockerClient.environment", "env1=val1,env2=val2");
assertThat(testJibExtension.getDockerClient().getEnvironment())
.containsExactly("env1", "val1", "env2", "val2")
.inOrder();
// Absolute paths
System.setProperty("jib.outputPaths.digest", "/digest/path");
ass... | @@ -335,125 +324,122 @@ public void testSkaffold() {
});
});
Path root = fakeProject.getRootDir().toPath();
- Assert.assertEquals(
- ImmutableSet.of(
- root.resolve("sync1").toAbsolutePath(), root.resolve("sync2").toAbsolutePath()),
- testJibExtension.getSkaffold... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java | 26 | Java | 0.714 | suggestion | 145 | 39 | 39 | false | Avoid potential Gradle issue of mutating immutable property | 3,121 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java
PR Title: Avoid potential Gradle issue of mutating immutable property
BEFORE CODE: System.setProperty("jib.dockerClient.environment", "env1=val1,env2=val2");
assertTh... | Since `runtimeClasspath` is the default, how about this?
```suggestion
System.setProperty("jib.configurationName", "myConfiguration");
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.containsExactly("env1", "val1", "env2", "val2")
.inOrder();
// Absolute paths
System.setProperty("jib.outputPaths.digest", "/digest/path");
assertThat(testJibExtension.getOutputPaths().getDigestPath())
.isEqualTo(Paths.get("/digest/path").toAbsolutePath());
System.setProperty("... | oops sorry and this:
```suggestion
assertThat(testJibExtension.getConfigurationName().get()).isEqualTo("myConfiguration");
}
``` | .containsExactly("env1", "val1", "env2", "val2")
.inOrder();
// Absolute paths
System.setProperty("jib.outputPaths.digest", "/digest/path");
assertThat(testJibExtension.getOutputPaths().getDigestPath())
.isEqualTo(Paths.get("/digest/path").toAbsolutePath());
System.setProperty("... | @@ -335,125 +324,122 @@ public void testSkaffold() {
});
});
Path root = fakeProject.getRootDir().toPath();
- Assert.assertEquals(
- ImmutableSet.of(
- root.resolve("sync1").toAbsolutePath(), root.resolve("sync2").toAbsolutePath()),
- testJibExtension.getSkaffold... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java | 26 | Java | 0.714 | suggestion | 138 | 37 | 37 | false | Avoid potential Gradle issue of mutating immutable property | 3,121 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java
PR Title: Avoid potential Gradle issue of mutating immutable property
BEFORE CODE: .containsExactly("env1", "val1", "env2", "val2")
.inOrder();
// Absolu... | oops sorry and this:
```suggestion
assertThat(testJibExtension.getConfigurationName().get()).isEqualTo("myConfiguration");
}
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
private final String name;
/**
* Initializes with a name for the layer.
*
* @param name name to set for the layer; does not affect the contents of the layer
*/
LayerType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
/**
*... | perhaps this?
```suggestion
* @deprecated Use {@code from()} with the image reference {@code gcr.io/distroless/java}.
``` |
private final String name;
/**
* Initializes with a name for the layer.
*
* @param name name to set for the layer; does not affect the contents of the layer
*/
LayerType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
/**
*... | @@ -90,7 +90,10 @@ public String getName() {
*
* @return a new {@link JavaContainerBuilder}
* @see <a href="https://github.com/GoogleContainerTools/distroless">The distroless repository</a>
+ * @deprecated Use other {@code from()} methods with the image reference {@code
+ * gcr.io/distroless/java}. | jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java | 26 | Java | 0.786 | suggestion | 128 | 51 | 51 | false | Deprecate Distroless methods in jib-core | 3,123 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java
PR Title: Deprecate Distroless methods in jib-core
BEFORE CODE:
private final String name;
/**
* Initializes with a name for the layer.
*
* @param name name ... | perhaps this?
```suggestion
* @deprecated Use {@code from()} with the image reference {@code gcr.io/distroless/java}.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
/**
* The default app root in the image. For example, if this is set to {@code "/app"}, dependency
* JARs will be in {@code "/app/libs"}.
*/
public static final String DEFAULT_APP_ROOT = "/app";
/**
* The default webapp root in the image. For example, if this is set to {@code
* "/jetty/webapp... | ```suggestion
* @deprecated Use {@code from()} with the image reference {@code
* gcr.io/distroless/java/jetty} and change the app root by calling {@code
* JavaContainerBuilder.setAppRoot("/jetty/webapps/ROOT")}.
``` |
/**
* The default app root in the image. For example, if this is set to {@code "/app"}, dependency
* JARs will be in {@code "/app/libs"}.
*/
public static final String DEFAULT_APP_ROOT = "/app";
/**
* The default webapp root in the image. For example, if this is set to {@code
* "/jetty/webapps/RO... | @@ -118,7 +123,11 @@ public static JavaContainerBuilder fromDistroless() {
*
* @return a new {@link JavaContainerBuilder}
* @see <a href="https://github.com/GoogleContainerTools/distroless">The distroless repository</a>
+ * @deprecated Use other {@code from()} methods with the image reference {@code
+ *... | jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java | 26 | Java | 0.857 | suggestion | 236 | 51 | 51 | false | Deprecate Distroless methods in jib-core | 3,123 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java
PR Title: Deprecate Distroless methods in jib-core
BEFORE CODE: }
/**
* The default app root in the image. For example, if this is set to {@code "/app"}, dependency
* JARs... | ```suggestion
* @deprecated Use {@code from()} with the image reference {@code
* gcr.io/distroless/java/jetty} and change the app root by calling {@code
* JavaContainerBuilder.setAppRoot("/jetty/webapps/ROOT")}.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
volumes.add(absoluteUnixPath);
} catch (IllegalArgumentException exception) {
throw new InvalidContainerVolumeException(path, path, exception);
}
}
return volumes;
}
/**
* Gets the value of the {@code appRoot} parameter. If the parameter is empty, returns {@link
* JavaCon... | Let's change the javadoc as well? | volumes.add(absoluteUnixPath);
} catch (IllegalArgumentException exception) {
throw new InvalidContainerVolumeException(path, path, exception);
}
}
return volumes;
}
/**
* Gets the value of the {@code appRoot} parameter. If the parameter is empty, returns {@code
* /jetty/... | @@ -735,7 +737,7 @@ static AbsoluteUnixPath getAppRootChecked(
if (appRoot.isEmpty()) {
appRoot = | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java | 26 | Java | 0.143 | question | 33 | 51 | 51 | false | Deprecate Distroless methods in jib-core | 3,123 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
PR Title: Deprecate Distroless methods in jib-core
BEFORE CODE: volumes.add(absoluteUnixPath);
} catch (IllegalArgumentException exception)... | Let's change the javadoc as well? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/*
* Copyright 2019 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | ```suggestion
* {@code adoptopenjdk:8-jre}.
``` | /*
* Copyright 2019 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | @@ -19,7 +19,7 @@
/**
* Exception when the Java version in the base image is incompatible with the Java version of the
* application to be containerized. For example, when the project is Java 11 but the base image is
- * {@code gcr.io/distroless/java:8}.
+ * {@code adoptopenjdk:8-jre-slim}. | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/IncompatibleBaseImageJavaVersionException.java | 22 | Java | 0.571 | suggestion | 50 | 43 | 43 | false | Change the default base images from Distroless in Jib build plugins | 3,124 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/IncompatibleBaseImageJavaVersionException.java
PR Title: Change the default base images from Distroless in Jib build plugins
BEFORE CODE: /*
* Copyright 2019 Google LLC.
*
* Licensed u... | ```suggestion
* {@code adoptopenjdk:8-jre}.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/**
* The default app root in the image. For example, if this is set to {@code "/app"}, dependency
* JARs will be in {@code "/app/libs"}.
*/
public static final String DEFAULT_APP_ROOT = "/app";
/**
* The default webapp root in the image. For example, if this is set to {@code
* "/jetty/webapps/RO... | Does this need to be?:
```suggestion
* JavaContainerBuilder.setAppRoot("var/lib/jetty/webapps/ROOT")}. However, using Distroless Java is
* no longer recommended.
``` | /**
* The default app root in the image. For example, if this is set to {@code "/app"}, dependency
* JARs will be in {@code "/app/libs"}.
*/
public static final String DEFAULT_APP_ROOT = "/app";
/**
* The default webapp root in the image. For example, if this is set to {@code
* "/jetty/webapps/ROO... | @@ -124,7 +125,8 @@ public static JavaContainerBuilder fromDistroless() {
* @see <a href="https://github.com/GoogleContainerTools/distroless">The distroless repository</a>
* @deprecated Use {@code from()} with the image reference {@code gcr.io/distroless/java/jetty}
* and change the app root by calling ... | jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java | 26 | Java | 0.714 | question | 183 | 51 | 51 | false | Change the default base images from Distroless in Jib build plugins | 3,124 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java
PR Title: Change the default base images from Distroless in Jib build plugins
BEFORE CODE:
/**
* The default app root in the image. For example, if this is set to {@code "/app"... | Does this need to be?:
```suggestion
* JavaContainerBuilder.setAppRoot("var/lib/jetty/webapps/ROOT")}. However, using Distroless Java is
* no longer recommended.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
|| !rawExtraClasspath.isEmpty()
|| rawConfiguration.getExpandClasspathDependencies()) {
projectProperties.log(
LogEvent.warn(
"mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies are ignored "
+ "when entrypoint is specified"))... | FTR: it was wrong to return this when a custom base image is specified. The issue is fixed later in #3185. | || !rawConfiguration.getJvmFlags().isEmpty()
|| !rawExtraClasspath.isEmpty()
|| rawConfiguration.getExpandClasspathDependencies()) {
projectProperties.log(
LogEvent.warn(
"mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies are ignored "... | @@ -588,7 +589,7 @@ static JavaContainerBuilder getJavaContainerBuilderWithBaseImage(
"mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies "
+ "are ignored for WAR projects"));
}
- return null;
+ return Arrays.asList("java", "-jar", "/usr/local/jet... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java | 26 | Java | 0.357 | bug | 106 | 51 | 51 | false | Change the default base images from Distroless in Jib build plugins | 3,124 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
PR Title: Change the default base images from Distroless in Jib build plugins
BEFORE CODE: || !rawExtraClasspath.isEmpty()
|| rawConf... | FTR: it was wrong to return this when a custom base image is specified. The issue is fixed later in #3185. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
public class GradleLayerConfigurationIntegrationTest {
@ClassRule
public static final TestProject multiTestProject = new TestProject("all-local-multi-service");
@ClassRule public static final TestProject configTestProject = new TestPro... | .containsExactly(...).inOrder()? | import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
public class GradleLayerConfigurationIntegrationTest {
@ClassRule
public static final TestProject multiTestProject = new TestProject("all-local-multi-service");
@ClassRule public static final TestProject configTestProject = new TestPro... | @@ -34,6 +36,46 @@
@ClassRule
public static final TestProject multiTestProject = new TestProject("all-local-multi-service");
+ @ClassRule public static final TestProject configTestProject = new TestProject("simple");
+
+ @Test
+ public void testGradleLayerConfiguration_configurationName() throws IOException ... | jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/GradleLayerConfigurationIntegrationTest.java | 26 | Java | 0.071 | question | 32 | 51 | 51 | false | Add Integration testing for new jib-gradle-plugin option `configurationName` | 3,125 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/GradleLayerConfigurationIntegrationTest.java
PR Title: Add Integration testing for new jib-gradle-plugin option `configurationName`
BEFORE CODE: import org.junit.Assert;
import org.jun... | .containsExactly(...).inOrder()? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@Test
public void testNonWebAppProject() {
Project project = createProject("java", "com.google.cloud.tools.jib");
TaskContainer tasks = project.getTasks();
Exception exception = assertThrows(UnknownTaskException.class, () -> tasks.getByPath(":war"));
assertThat(exception).hasMessageThat().isNotNull... | nit: while we're at it, since we use `assertThat().contains()`,
```suggestion
String output = exception.getBuildResult().getOutput();
``` | @Test
public void testNonWebAppProject() {
Project project = createProject("java", "com.google.cloud.tools.jib");
TaskContainer tasks = project.getTasks();
Exception exception = assertThrows(UnknownTaskException.class, () -> tasks.getByPath(":war"));
assertThat(exception).hasMessageThat().isNotNull... | @@ -347,16 +347,13 @@ public void testJibTaskGroupIsSet() {
@Test
public void testLazyEvalForImageAndTags() {
- // TODO: Pass in `-Djib.console=plain` as argument for build and remove filtering for cyan
- // coloring regex once [#2764](https://github.com/GoogleContainerTools/jib/issues/2764) is
- // su... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibPluginTest.java | 26 | Java | 0.929 | suggestion | 144 | 39 | 39 | false | Resolve TODO and update CHANGELOGs to reflect changes in #2764 | 3,129 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibPluginTest.java
PR Title: Resolve TODO and update CHANGELOGs to reflect changes in #2764
BEFORE CODE: @Test
public void testNonWebAppProject() {
Project project = createProject("java", ... | nit: while we're at it, since we use `assertThat().contains()`,
```suggestion
String output = exception.getBuildResult().getOutput();
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.... | nit:
```suggestion
assertThat(logger.getHandlers()).hasLength(1);
``` | * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.... | @@ -0,0 +1,40 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by ... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java | 26 | Java | 0.714 | suggestion | 76 | 32 | 32 | false | Implement --http-trace in Jib CLI | 3,130 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java
PR Title: Implement --http-trace in Jib CLI
BEFORE CODE: * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BA... | nit:
```suggestion
assertThat(logger.getHandlers()).hasLength(1);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public void testWriteLocalConfig() throws IOException, URISyntaxException, DigestException {
ContainerConfigurationTemplate containerConfigurationTemplate =
loadJsonResource("core/json/containerconfig.json", ContainerConfigurationTemplate.class);
cacheStorageWriter.writeLocalConfig(
Descripto... | ```suggestion
() -> CacheStorageWriter.moveIfDoesNotExist(Paths.get("foo"), Paths.get("bar")));
``` | public void testWriteLocalConfig() throws IOException, URISyntaxException, DigestException {
ContainerConfigurationTemplate containerConfigurationTemplate =
loadJsonResource("core/json/containerconfig.json", ContainerConfigurationTemplate.class);
cacheStorageWriter.writeLocalConfig(
Descripto... | @@ -336,6 +340,23 @@ public void testWriteLocalConfig() throws IOException, URISyntaxException, Diges
Assert.assertEquals("wasm", savedContainerConfig.getArchitecture());
}
+ @Test
+ public void testMoveIfDoesNotExist_exceptionAfterFailure() {
+ Exception exception =
+ assertThrows(
+ I... | jib-core/src/test/java/com/google/cloud/tools/jib/cache/CacheStorageWriterTest.java | 26 | Java | 0.786 | performance | 113 | 51 | 51 | false | Increase retry attempts and fix the issue of exception being consumed | 3,133 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/test/java/com/google/cloud/tools/jib/cache/CacheStorageWriterTest.java
PR Title: Increase retry attempts and fix the issue of exception being consumed
BEFORE CODE: public void testWriteLocalConfig() throws IOException, URISyntaxException, DigestEx... | ```suggestion
() -> CacheStorageWriter.moveIfDoesNotExist(Paths.get("foo"), Paths.get("bar")));
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
containerConfigurationTemplate);
Path savedConfigPath =
cacheStorageFiles
.getLocalDirectory()
.resolve("config")
.resolve("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
Assert.assertTrue(Files.exists(savedConfigPath));
ContainerConf... | sometimes asserting on the whole message can make the test brittle. How about we assert on just the essential part? : `unable to move: /foo to /bar; such failures are often caused by interference from antivirus` | containerConfigurationTemplate);
Path savedConfigPath =
cacheStorageFiles
.getLocalDirectory()
.resolve("config")
.resolve("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
Assert.assertTrue(Files.exists(savedConfigPath));
ContainerConf... | @@ -336,6 +340,23 @@ public void testWriteLocalConfig() throws IOException, URISyntaxException, Diges
Assert.assertEquals("wasm", savedContainerConfig.getArchitecture());
}
+ @Test
+ public void testMoveIfDoesNotExist_exceptionAfterFailure() {
+ Exception exception =
+ assertThrows(
+ I... | jib-core/src/test/java/com/google/cloud/tools/jib/cache/CacheStorageWriterTest.java | 26 | Java | 0.643 | bug | 211 | 50 | 48 | false | Increase retry attempts and fix the issue of exception being consumed | 3,133 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/test/java/com/google/cloud/tools/jib/cache/CacheStorageWriterTest.java
PR Title: Increase retry attempts and fix the issue of exception being consumed
BEFORE CODE: containerConfigurationTemplate);
Path savedConfigPath =
cacheSto... | sometimes asserting on the whole message can make the test brittle. How about we assert on just the essential part? : `unable to move: /foo to /bar; such failures are often caused by interference from antivirus` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/**
* Adds a blob to the archive. Note that this should be used with raw bytes and not file contents;
* for adding files to the archive, use {@link #addTarArchiveEntry}.
*
* @param contents the bytes to add to the tarball
* @param name the name of the entry (i.e. filename)
*/
public void addByteE... | I realized that this isn't enough. The `addByteEntry()` above also needs to set the timestamp. Both `addBlobEntry()` and `addByteEntry()` are used in `ImageTarball` to create a tar image stream.
However, we have layers of abstraction in our codebase with a hierarchy, so it doesn't feel right to make `TarStreamBuilde... | /**
* Adds a blob to the archive. Note that this should be used with raw bytes and not file contents;
* for adding files to the archive, use {@link #addTarArchiveEntry}.
*
* @param contents the bytes to add to the tarball
* @param name the name of the entry (i.e. filename)
* @param modificationTime ... | @@ -89,6 +91,7 @@ public void addByteEntry(byte[] contents, String name) {
public void addBlobEntry(Blob blob, long size, String name) {
TarArchiveEntry entry = new TarArchiveEntry(name);
entry.setSize(size);
+ entry.setModTime(DEFAULT_MODIFICATION_TIME.getEpochSecond()); | jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java | 26 | Java | 0.643 | refactor | 616 | 30 | 32 | false | #3158 - [Jib core] Tar archives with same contents are not reproducible | 3,159 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | davidtron | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java
PR Title: #3158 - [Jib core] Tar archives with same contents are not reproducible
BEFORE CODE:
/**
* Adds a blob to the archive. Note that this should be used with raw bytes and no... | I realized that this isn't enough. The `addByteEntry()` above also needs to set the timestamp. Both `addBlobEntry()` and `addByteEntry()` are used in `ImageTarball` to create a tar image stream.
However, we have layers of abstraction in our codebase with a hierarchy, so it doesn't feel right to make `TarStreamBuilde... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import com.google.cloud.tools.jib.json.JsonTemplate;
import com.google.cloud.tools.jib.json.JsonTemplateMapper;
import com.google.cloud.tools.jib.tar.TarStreamBuilder;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import... | ```suggestion
private static final Instant TAR_ENTRY_MODIFICATION_TIME = Instant.EPOCH;
```
and move the field up. | import com.google.cloud.tools.jib.json.JsonTemplate;
import com.google.cloud.tools.jib.json.JsonTemplateMapper;
import com.google.cloud.tools.jib.tar.TarStreamBuilder;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import... | @@ -48,6 +49,7 @@
private final Image image;
private final ImageReference imageReference;
private final ImmutableSet<String> allTargetImageTags;
+ private final Instant creationTime = Instant.EPOCH; | jib-core/src/main/java/com/google/cloud/tools/jib/image/ImageTarball.java | 26 | Java | 0.786 | suggestion | 119 | 51 | 51 | false | #3158 - [Jib core] Tar archives with same contents are not reproducible | 3,159 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | davidtron | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/image/ImageTarball.java
PR Title: #3158 - [Jib core] Tar archives with same contents are not reproducible
BEFORE CODE: import com.google.cloud.tools.jib.json.JsonTemplate;
import com.google.cloud.tools.jib.json.J... | ```suggestion
private static final Instant TAR_ENTRY_MODIFICATION_TIME = Instant.EPOCH;
```
and move the field up. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
tarArchiveOutputStream.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
for (Map.Entry<TarArchiveEntry, Blob> entry : archiveMap.entrySet()) {
tarArchiveOutputStream.putArchiveEntry(entry.getKey());
entry.getValue().writeTo(tarArchiveOutputStream);
tarArchiveOutputStream.clo... | ```suggestion
* @param modificationTime the modification time of the entry
``` | tarArchiveOutputStream.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
for (Map.Entry<TarArchiveEntry, Blob> entry : archiveMap.entrySet()) {
tarArchiveOutputStream.putArchiveEntry(entry.getKey());
entry.getValue().writeTo(tarArchiveOutputStream);
tarArchiveOutputStream.clo... | @@ -71,10 +72,12 @@ public void addTarArchiveEntry(TarArchiveEntry entry) {
*
* @param contents the bytes to add to the tarball
* @param name the name of the entry (i.e. filename)
+ * @param modTime the time the entry is created | jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java | 26 | Java | 0.571 | suggestion | 83 | 51 | 51 | false | #3158 - [Jib core] Tar archives with same contents are not reproducible | 3,159 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | davidtron | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java
PR Title: #3158 - [Jib core] Tar archives with same contents are not reproducible
BEFORE CODE: tarArchiveOutputStream.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
... | ```suggestion
* @param modificationTime the modification time of the entry
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
tarArchiveOutputStream.putArchiveEntry(entry.getKey());
entry.getValue().writeTo(tarArchiveOutputStream);
tarArchiveOutputStream.closeArchiveEntry();
}
}
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarArchiveEntry}
*/
public voi... | ```suggestion
public void addByteEntry(byte[] contents, String name, Instant modificationTime) {
``` | tarArchiveOutputStream.putArchiveEntry(entry.getKey());
entry.getValue().writeTo(tarArchiveOutputStream);
tarArchiveOutputStream.closeArchiveEntry();
}
}
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarArchiveEntry}
*/
public voi... | @@ -71,10 +72,12 @@ public void addTarArchiveEntry(TarArchiveEntry entry) {
*
* @param contents the bytes to add to the tarball
* @param name the name of the entry (i.e. filename)
+ * @param modTime the time the entry is created
*/
- public void addByteEntry(byte[] contents, String name) {
+ public ... | jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java | 26 | Java | 0.714 | suggestion | 104 | 49 | 49 | false | #3158 - [Jib core] Tar archives with same contents are not reproducible | 3,159 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | davidtron | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java
PR Title: #3158 - [Jib core] Tar archives with same contents are not reproducible
BEFORE CODE: tarArchiveOutputStream.putArchiveEntry(entry.getKey());
entry.getValue().wr... | ```suggestion
public void addByteEntry(byte[] contents, String name, Instant modificationTime) {
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@Test
public void testToBlob_tarArchiveEntriesWithCompression() throws IOException {
setUpWithTarEntries();
verifyBlobWithCompression();
}
@Test
public void testToBlob_stringsWithCompression() throws IOException {
setUpWithStrings();
verifyBlobWithCompression();
}
@Test
public void te... | In tests, just do
```suggestion
Blobs.from("jib"), "jib".getBytes(StandardCharsets.UTF_8).length, "jib", Instant.EPOCH);
``` | }
@Test
public void testToBlob_tarArchiveEntriesWithCompression() throws IOException {
setUpWithTarEntries();
verifyBlobWithCompression();
}
@Test
public void testToBlob_stringsWithCompression() throws IOException {
setUpWithStrings();
verifyBlobWithCompression();
}
@Test
public voi... | @@ -96,10 +98,11 @@ public void testToBlob_stringsAndTarArchiveEntriesWithCompression() throws IOExc
@Test
public void testToBlob_multiByte() throws IOException {
- testTarStreamBuilder.addByteEntry("日本語".getBytes(StandardCharsets.UTF_8), "test");
- testTarStreamBuilder.addByteEntry("asdf".getBytes(Standa... | jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarStreamBuilderTest.java | 26 | Java | 0.714 | suggestion | 135 | 51 | 51 | false | #3158 - [Jib core] Tar archives with same contents are not reproducible | 3,159 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | davidtron | Review this pull request change.
Language: Java
File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarStreamBuilderTest.java
PR Title: #3158 - [Jib core] Tar archives with same contents are not reproducible
BEFORE CODE:
@Test
public void testToBlob_tarArchiveEntriesWithCompression() throws IOException... | In tests, just do
```suggestion
Blobs.from("jib"), "jib".getBytes(StandardCharsets.UTF_8).length, "jib", Instant.EPOCH);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
}
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarArchiveEntry}
*/
public void addTarArchiveEntry(TarArchiveEntry entry) {
archiveMap.put(
entry, entry.isFile() ? Blobs.from(entry.getFile().toPath()) : Blobs.from(ignored -> {}));
}
/*... | Shouldn't this be `toEpochMillis()`? I guess writing a test will confirm it. | }
}
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarArchiveEntry}
*/
public void addTarArchiveEntry(TarArchiveEntry entry) {
archiveMap.put(
entry, entry.isFile() ? Blobs.from(entry.getFile().toPath()) : Blobs.from(ignored -> {}));
}
/*... | @@ -71,10 +72,12 @@ public void addTarArchiveEntry(TarArchiveEntry entry) {
*
* @param contents the bytes to add to the tarball
* @param name the name of the entry (i.e. filename)
+ * @param modificationTime the modification time of the entry
*/
- public void addByteEntry(byte[] contents, String name... | jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java | 26 | Java | 0.429 | suggestion | 76 | 46 | 46 | false | #3158 - [Jib core] Tar archives with same contents are not reproducible | 3,159 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | davidtron | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java
PR Title: #3158 - [Jib core] Tar archives with same contents are not reproducible
BEFORE CODE: }
}
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @par... | Shouldn't this be `toEpochMillis()`? I guess writing a test will confirm it. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Logger logger = Logger.getLogger(HttpTransport.class.getName());
logger.setLevel(level);
logger.addHandler(consoleHandler);
return logger;
}
static void logTerminatingException(
ConsoleLogger consoleLogger, Exception exception, boolean logStackTrace) {
if (logStackTrace) {
StringWri... | I think when the verbosity >= info. | static Logger configureHttpLogging(Level level) {
// To instantiate the static HttpTransport logger field.
// Fixes https://github.com/GoogleContainerTools/jib/issues/3156.
new ApacheHttpTransport();
ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(level);
Logger ... | @@ -67,6 +79,45 @@ static void logTerminatingException(
+ "\u001B[0m");
}
+ static Future<Optional<String>> newUpdateChecker(
+ GlobalConfig globalConfig, Verbosity verbosity, Consumer<LogEvent> log) {
+ if (!verbosity.equals(Verbosity.info) || globalConfig.isDisableUpdateCheck()) { | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java | 26 | Java | 0.071 | suggestion | 35 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: Logger logger = Logger.getLogger(HttpTransport.class.getName());
logger.setLevel(level);
logger.addHandler(consoleHandler);
... | I think when the verbosity >= info. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
StringWriter writer = new StringWriter();
exception.printStackTrace(new PrintWriter(writer));
consoleLogger.log(LogEvent.Level.ERROR, writer.toString());
}
consoleLogger.log(
LogEvent.Level.ERROR,
"\u001B[31;1m"
+ exception.getClass().getName()
+ ": "
... | So `.getPackage()` works only when the `JibCli` is packaged in a `.jar` file, which is true now. But I fear it may not work when we generate a native executable. Should we use `VersionInfo.TOOL_NAME` and `VersionInfo.getSimpleVersion()`? | logger.addHandler(consoleHandler);
return logger;
}
static void logTerminatingException(
ConsoleLogger consoleLogger, Exception exception, boolean logStackTrace) {
if (logStackTrace) {
StringWriter writer = new StringWriter();
exception.printStackTrace(new PrintWriter(writer));
... | @@ -67,6 +79,45 @@ static void logTerminatingException(
+ "\u001B[0m");
}
+ static Future<Optional<String>> newUpdateChecker(
+ GlobalConfig globalConfig, Verbosity verbosity, Consumer<LogEvent> log) {
+ if (!verbosity.equals(Verbosity.info) || globalConfig.isDisableUpdateCheck()) {
+ re... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java | 26 | Java | 0.643 | question | 237 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: StringWriter writer = new StringWriter();
exception.printStackTrace(new PrintWriter(writer));
consoleLogger.log(LogEven... | So `.getPackage()` works only when the `JibCli` is packaged in a `.jar` file, which is true now. But I fear it may not work when we generate a native executable. Should we use `VersionInfo.TOOL_NAME` and `VersionInfo.getSimpleVersion()`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
httpClient.get(
new URL(versionUrl),
Request.builder()
.setHttpTimeout(3000)
.setUserAgent("jib " + currentVersion + " " + toolName)
.build());
VersionJsonTemplate version =
JsonTemplateMapper.rea... | So I think we want to customize the update message. For Jib CLI, it'll really help if it can directly present the GitHub Release for the new version. | httpClient.get(
new URL(versionUrl),
Request.builder()
.setHttpTimeout(3000)
.setUserAgent("jib " + currentVersion + " " + toolName)
.build());
VersionJsonTemplate version =
JsonTemplateMapper.rea... | @@ -122,11 +122,13 @@
return Optional.empty();
}
return Optional.of(
- "A new version of Jib ("
+ "A new version of "
+ + toolName
+ + " ("
+ version.latest
+ ") is available (currently using "
... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java | 26 | Java | 0.357 | suggestion | 149 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: httpClient.get(
new URL(versionUrl),
Request.builder()
... | So I think we want to customize the update message. For Jib CLI, it'll really help if it can directly present the GitHub Release for the new version. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public void testLogTerminatingException() {
JibCli.logTerminatingException(logger, new IOException("test error message"), false);
verify(logger)
.log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
verifyNoMoreInteractions(logger);
}
@Test
public void... | ```suggestion
assertThat(updateChecker.get()).isEmpty();
``` |
@Mock private JibContainer mockJibContainer;
@Test
public void testConfigureHttpLogging() {
Logger logger = JibCli.configureHttpLogging(Level.ALL);
assertThat(logger.getName()).isEqualTo("com.google.api.client.http.HttpTransport");
assertThat(logger.getLevel()).isEqualTo(Level.ALL);
assertThat(... | @@ -68,4 +82,12 @@ public void testLogTerminatingException_stackTrace() {
.log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
verifyNoMoreInteractions(logger);
}
+
+ @Test
+ public void testNewUpdateChecker_noUpdateCheck() throws ExecutionException, Interrupted... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java | 26 | Java | 0.571 | suggestion | 66 | 29 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: public void testLogTerminatingException() {
JibCli.logTerminatingException(logger, new IOException("test error message"), false... | ```suggestion
assertThat(updateChecker.get()).isEmpty();
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
new URL(versionUrl),
Request.builder()
.setHttpTimeout(3000)
.setUserAgent("jib " + currentVersion + " " + toolName)
.build());
VersionJsonTemplate version =
JsonTemplateMapper.readJson(response.getBody(), Ve... | Hmm... although it works, I think this is too hacky to accept. Maybe we can make this method return only the latest version string (i.e., `version.latest`), and have the caller construct the message (maybe in `finishUpdateChecker`)? Or, any other thoughts? | new URL(versionUrl),
Request.builder()
.setHttpTimeout(3000)
.setUserAgent("jib " + currentVersion + " " + toolName)
.build());
VersionJsonTemplate version =
JsonTemplateMapper.readJson(response.getBody(), Ve... | @@ -121,12 +121,22 @@
if (currentVersion.equals(version.latest)) {
return Optional.empty();
}
- return Optional.of(
- "A new version of Jib ("
+ String updateMessage =
+ "A new version of "
+ + toolName
+ + " ("
... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java | 26 | Java | 0.571 | question | 256 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: new URL(versionUrl),
Request.builder()
.setHttpTimeout(3... | Hmm... although it works, I think this is too hacky to accept. Maybe we can make this method return only the latest version string (i.e., `version.latest`), and have the caller construct the message (maybe in `finishUpdateChecker`)? Or, any other thoughts? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.setUserAgent("jib " + currentVersion + " " + toolName)
.build());
VersionJsonTemplate version =
JsonTemplateMapper.readJson(response.getBody(), VersionJsonTemplate.class);
Path lastUpdateCheckTemp =
Files.createTempFile(configDir, LAST_UP... | And since we have the `version.latest`, I think we can directly link the Release with the target version? | .setUserAgent("jib " + currentVersion + " " + toolName)
.build());
VersionJsonTemplate version =
JsonTemplateMapper.readJson(response.getBody(), VersionJsonTemplate.class);
Path lastUpdateCheckTemp =
Files.createTempFile(configDir, LAST_UP... | @@ -121,12 +121,22 @@
if (currentVersion.equals(version.latest)) {
return Optional.empty();
}
- return Optional.of(
- "A new version of Jib ("
+ String updateMessage =
+ "A new version of "
+ + toolName
+ + " ("
... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java | 26 | Java | 0.5 | question | 105 | 51 | 49 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: .setUserAgent("jib " + currentVersion + " " + toolName)
.build());
... | And since we have the `version.latest`, I think we can directly link the Release with the target version? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.Futures;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import jav... | I find no need to declare it as a constant field. | import com.google.cloud.tools.jib.plugins.common.globalconfig.GlobalConfig;
import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.Futures;
import java.io.IOException;
import java.io.PrintWriter;
import jav... | @@ -37,6 +48,9 @@
subcommands = {Build.class, Jar.class})
public class JibCli {
+ private static final String VERSION_URL = "https://storage.googleapis.com/jib-versions/jib-cli";
+ private static final String TOOL_VERSION = VersionInfo.getVersionSimple(); | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java | 26 | Java | 0.071 | suggestion | 49 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.Futures;
import java.io.PrintWriter;
imp... | I find no need to declare it as a constant field. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
}
@VisibleForTesting
static void finishUpdateChecker(
ConsoleLogger logger, Future<Optional<String>> updateCheckFuture) {
UpdateChecker.finishUpdateCheck(updateCheckFuture)
.ifPresent(
latestVersion -> {
logger.log(
LogEvent.Level.LIFECYCLE,
... | I think we should have `\n` after this. Maybe `\n\n` is better?
It's a bit hard to parse this and check if this is correctly formed. Maybe `String.format` can improve readability? And I think we can just embed "Jib CLI" without `VersionInfo.TOOL_NAME`.
```java
String message = "A new version of Jib CLI (%d) is a... | try {
return UpdateChecker.checkForUpdate(
executorService, VERSION_URL, VersionInfo.TOOL_NAME, VersionInfo.getVersionSimple(), log);
} finally {
executorService.shutdown();
}
}
@VisibleForTesting
static void finishUpdateChecker(
ConsoleLogger logger, Future<Optional<Strin... | @@ -67,6 +81,49 @@ static void logTerminatingException(
+ "\u001B[0m");
}
+ static Future<Optional<String>> newUpdateChecker(
+ GlobalConfig globalConfig, Verbosity verbosity, Consumer<LogEvent> log) {
+ if (!verbosity.atLeast(Verbosity.info) || globalConfig.isDisableUpdateCheck()) {
+ r... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java | 26 | Java | 0.857 | style | 483 | 46 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: }
}
@VisibleForTesting
static void finishUpdateChecker(
ConsoleLogger logger, Future<Optional<String>> updateCheckFuture... | I think we should have `\n` after this. Maybe `\n\n` is better?
It's a bit hard to parse this and check if this is correctly formed. Maybe `String.format` can improve readability? And I think we can just embed "Jib CLI" without `VersionInfo.TOOL_NAME`.
```java
String message = "A new version of Jib CLI (%d) is a... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Project project = ProjectBuilder.builder().build();
project.getPlugins().apply(JavaPlugin.class);
TaskProvider<Task> warProviderTask = TaskCommon.getWarTaskProvider(project);
assertThat(warProviderTask).isNull();
}
@Test
public void testGetWarTask_normalWarProject() {
Project project = Proje... | Doesn't it have `assertThat(bootWarTask).isInstanceOf(...)`? | Project project = ProjectBuilder.builder().build();
project.getPlugins().apply(JavaPlugin.class);
TaskProvider<Task> warProviderTask = TaskCommon.getWarTaskProvider(project);
assertThat(warProviderTask).isNull();
}
@Test
public void testGetWarTask_normalWarProject() {
Project project = Proje... | @@ -71,7 +82,26 @@ public void testGetBootWarTask_bootWarProject() {
project.getPlugins().apply(SpringBootPlugin.class);
TaskProvider<Task> bootWarTask = TaskCommon.getBootWarTaskProvider(project);
- Assert.assertNotNull(bootWarTask);
- Assert.assertNotNull(bootWarTask instanceof BootWar);
+ assert... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/TaskCommonTest.java | 26 | Java | 0.357 | question | 60 | 48 | 48 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/TaskCommonTest.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: Project project = ProjectBuilder.builder().build();
project.getPlugins().apply(JavaPlugin.class);
TaskP... | Doesn't it have `assertThat(bootWarTask).isInstanceOf(...)`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
lastUpdateCheckTemp.toFile().deleteOnExit();
Files.write(lastUpdateCheckTemp, Instant.now().toString().getBytes(StandardCharsets.UTF_8));
Files.move(lastUpdateCheckTemp, lastUpdateCheck, StandardCopyOption.REPLACE_EXISTING);
if (currentVersion.equals(version.latest)) {
return ... | ```suggestion
* @return the latest version, if found
``` | lastUpdateCheckTemp.toFile().deleteOnExit();
Files.write(lastUpdateCheckTemp, Instant.now().toString().getBytes(StandardCharsets.UTF_8));
Files.move(lastUpdateCheckTemp, lastUpdateCheck, StandardCopyOption.REPLACE_EXISTING);
if (currentVersion.equals(version.latest)) {
return ... | @@ -140,9 +134,9 @@
}
/**
- * Returns a message indicating Jib should be upgraded if the check succeeded and the current
- * version is outdated, or returns {@code Optional.empty()} if the check was interrupted or did
- * not determine that a later version was available.
+ * Returns the latest Jib versi... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java | 26 | Java | 0.571 | suggestion | 61 | 43 | 42 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/UpdateChecker.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: lastUpdateCheckTemp.toFile().deleteOnExit();
Files.write(lastUpdateCheckTemp, Instant.now().... | ```suggestion
* @return the latest version, if found
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/** Collection of common methods to share between Gradle tasks. */
class TaskCommon {
public static final String VERSION_URL = "https://storage.googleapis.com/jib-versions/jib-gradle";
static Future<Optional<String>> newUpdateChecker(
ProjectProperties projectProperties, GlobalConfig globalConfig, Logger lo... | The method is required to be package-private, not just for testing.
```suggestion
``` | class TaskCommon {
public static final String VERSION_URL = "https://storage.googleapis.com/jib-versions/jib-gradle";
static Future<Optional<String>> newUpdateChecker(
ProjectProperties projectProperties, GlobalConfig globalConfig, Logger logger) {
if (projectProperties.isOffline()
|| !logger.is... | @@ -67,19 +68,27 @@
}
}
+ @VisibleForTesting | jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TaskCommon.java | 26 | Java | 0.571 | suggestion | 87 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TaskCommon.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: /** Collection of common methods to share between Gradle tasks. */
class TaskCommon {
public static final String VERS... | The method is required to be package-private, not just for testing.
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return Futures.immediateFuture(Optional.empty());
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
return UpdateChecker.checkForUpdate(
executorService,
VERSION_URL,
projectProperties.getToolName(),
projectProperties.getToolVe... | Sorry, missed this. For Maven, we intentionally use multiple `.log()`s instead of `\n` when we need to start a new line. Not a big deal, but this is because Maven prepends the verbosity info on every line, for example,
```
[INFO] Containerizing application to francium25/test...
``` | return Futures.immediateFuture(Optional.empty());
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
return UpdateChecker.checkForUpdate(
executorService,
VERSION_URL,
projectProperties.getToolName(),
projectProperties.getToolVe... | @@ -76,18 +76,21 @@ static void finishUpdateChecker(
ProjectProperties projectProperties, Future<Optional<String>> updateCheckFuture) {
UpdateChecker.finishUpdateCheck(updateCheckFuture)
.ifPresent(
- updateMessage -> {
- projectProperties.log(LogEvent.lifecycle(""));
- ... | jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MojoCommon.java | 26 | Java | 0.857 | suggestion | 285 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MojoCommon.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: return Futures.immediateFuture(Optional.empty());
}
ExecutorService executorService = Executors.newSingleThr... | Sorry, missed this. For Maven, we intentionally use multiple `.log()`s instead of `\n` when we need to start a new line. Not a big deal, but this is because Maven prepends the verbosity info on every line, for example,
```
[INFO] Containerizing application to francium25/test...
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
return UpdateChecker.checkForUpdate(
executorService,
VERSION_URL,
projectProperties.getToolName(),
projectProperties.getToolVersion(),
projectProperties::log);
} finall... | Let's not add `.` after a URL. Some terminal cannot determine if the last `.` should be part of a URL, and clicking on the link in the terminal may lead to 404 page not found.
```suggestion
+ " build configuration to use the latest features and fixes!\n%s\u001B[0m\n\nPlease see"
```
Check ... | }
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
return UpdateChecker.checkForUpdate(
executorService,
VERSION_URL,
projectProperties.getToolName(),
projectProperties.getToolVersion(),
projectProperties::log);
} finall... | @@ -76,18 +76,21 @@ static void finishUpdateChecker(
ProjectProperties projectProperties, Future<Optional<String>> updateCheckFuture) {
UpdateChecker.finishUpdateCheck(updateCheckFuture)
.ifPresent(
- updateMessage -> {
- projectProperties.log(LogEvent.lifecycle(""));
- ... | jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MojoCommon.java | 26 | Java | 0.857 | suggestion | 375 | 51 | 51 | false | Implement update checker for Jib CLI | 3,165 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MojoCommon.java
PR Title: Implement update checker for Jib CLI
BEFORE CODE: }
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
return UpdateChecker.chec... | Let's not add `.` after a URL. Some terminal cannot determine if the last `.` should be part of a URL, and clicking on the link in the terminal may lead to 404 page not found.
```suggestion
+ " build configuration to use the latest features and fixes!\n%s\u001B[0m\n\nPlease see"
```
Check ... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
getJavaContainerBuilderWithBaseImage(
rawConfiguration, projectProperties, inferredAuthProvider)
.setAppRoot(getAppRootChecked(rawConfiguration, projectProperties))
.setModificationTimeProvider(modificationTimeProvider);
JibContainerBuilder jibContainerBuilder =
... | nit: we can store `extraDirectory.getFrom()` in a variable? | getJavaContainerBuilderWithBaseImage(
rawConfiguration, projectProperties, inferredAuthProvider)
.setAppRoot(getAppRootChecked(rawConfiguration, projectProperties))
.setModificationTimeProvider(modificationTimeProvider);
JibContainerBuilder jibContainerBuilder =
... | @@ -429,15 +429,12 @@ static JibContainerBuilder processCommonConfiguration(
getCreationTime(rawConfiguration.getCreationTime(), projectProperties));
// Adds all the extra files.
- for (Map.Entry<Path, AbsoluteUnixPath> entry :
- rawConfiguration.getExtraDirectories().entrySet()) {
- Path... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java | 26 | Java | 0.357 | question | 59 | 51 | 51 | false | Add inclusion/exclusion filtering configuration for ExtraDirectories in Maven and Gradle | 3,171 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
PR Title: Add inclusion/exclusion filtering configuration for ExtraDirectories in Maven and Gradle
BEFORE CODE: getJavaContainerBuilderWithBaseIm... | nit: we can store `extraDirectory.getFrom()` in a variable? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.map(pattern -> FileSystems.getDefault().getPathMatcher("glob:" + pattern))
.map(pathMatcher -> (Predicate<Path>) (path -> pathMatcher.matches(path)))
.reduce((matches1, matches2) -> matches1.or(matches2))
.ifPresent(walker::filter);
walker.walk(
localPath -> {
Abso... | ```suggestion
}
// Add with explicit permissions
builder.addEntry(localPath, pathOnContainer, permissions, modificationTime);
``` | // add an inclusion filter
includes
.stream()
.map(pattern -> FileSystems.getDefault().getPathMatcher("glob:" + pattern))
.map(pathMatcher -> (Predicate<Path>) (path -> pathMatcher.matches(path)))
.reduce((matches1, matches2) -> matches1.or(matches2))
.ifPresent(walker::f... | @@ -64,33 +69,40 @@ public static FileEntriesLayer extraDirectoryLayerConfiguration(
FileSystems.getDefault().getPathMatcher("glob:" + entry.getKey()), entry.getValue());
}
- new DirectoryWalker(sourceDirectory)
- .filterRoot()
- .walk(
- localPath -> {
- Absol... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java | 26 | Java | 0.714 | security | 168 | 51 | 51 | false | <includes> and <excludes> filtering feature for extraDirectories | 3,173 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java
PR Title: <includes> and <excludes> filtering feature for extraDirectories
BEFORE CODE: .map(pattern -> FileSystems.getDefault().getPathMatcher("gl... | ```suggestion
}
// Add with explicit permissions
builder.addEntry(localPath, pathOnContainer, permissions, modificationTime);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
DirectoryWalker walker = new DirectoryWalker(sourceDirectory).filterRoot();
excludes
.stream()
.map(pattern -> FileSystems.getDefault().getPathMatcher("glob:" + pattern))
.forEach(pathMatcher -> walker.filter(path -> !pathMatcher.matches(path)));
includes
.stream()
... | there seem to be too many levels of nesting here, can we put this in a helper method? | FileSystems.getDefault().getPathMatcher("glob:" + entry.getKey()), entry.getValue());
}
DirectoryWalker walker = new DirectoryWalker(sourceDirectory).filterRoot();
// add exclusion filters
excludes
.stream()
.map(pattern -> FileSystems.getDefault().getPathMatcher("glob:" + pat... | @@ -64,33 +69,40 @@ public static FileEntriesLayer extraDirectoryLayerConfiguration(
FileSystems.getDefault().getPathMatcher("glob:" + entry.getKey()), entry.getValue());
}
- new DirectoryWalker(sourceDirectory)
- .filterRoot()
- .walk(
- localPath -> {
- Absol... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java | 26 | Java | 0.214 | refactor | 85 | 51 | 51 | false | <includes> and <excludes> filtering feature for extraDirectories | 3,173 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java
PR Title: <includes> and <excludes> filtering feature for extraDirectories
BEFORE CODE: }
DirectoryWalker walker = new DirectoryWalker(sourceDirec... | there seem to be too many levels of nesting here, can we put this in a helper method? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
throws IOException {
FileEntriesLayer.Builder builder =
FileEntriesLayer.builder().setName(LayerType.EXTRA_FILES.getName());
Map<PathMatcher, FilePermissions> pathMatchers = new LinkedHashMap<>();
for (Map.Entry<String, FilePermissions> entry : extraDirectoryPermissions.entrySet()) {
pat... | Hm this method is starting to get a little long, can we have line 83 - 105 in a separate method? | ModificationTimeProvider modificationTimeProvider)
throws IOException {
FileEntriesLayer.Builder builder =
FileEntriesLayer.builder().setName(LayerType.EXTRA_FILES.getName());
Map<PathMatcher, FilePermissions> permissionsPathMatchers = new LinkedHashMap<>();
for (Map.Entry<String, FilePe... | @@ -64,33 +69,40 @@ public static FileEntriesLayer extraDirectoryLayerConfiguration(
FileSystems.getDefault().getPathMatcher("glob:" + entry.getKey()), entry.getValue());
}
- new DirectoryWalker(sourceDirectory)
- .filterRoot()
- .walk(
- localPath -> {
- Absol... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java | 26 | Java | 0.214 | question | 96 | 51 | 51 | false | <includes> and <excludes> filtering feature for extraDirectories | 3,173 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java
PR Title: <includes> and <excludes> filtering feature for extraDirectories
BEFORE CODE: throws IOException {
FileEntriesLayer.Builder builder =
... | Hm this method is starting to get a little long, can we have line 83 - 105 in a separate method? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
List<String> excludes,
Map<String, FilePermissions> extraDirectoryPermissions,
ModificationTimeProvider modificationTimeProvider)
throws IOException {
FileEntriesLayer.Builder builder =
FileEntriesLayer.builder().setName(LayerType.EXTRA_FILES.getName());
Map<PathMatcher, FilePerm... | I'm probably missing something here, why is the `reduce` step needed here? | List<String> includes,
List<String> excludes,
Map<String, FilePermissions> extraDirectoryPermissions,
ModificationTimeProvider modificationTimeProvider)
throws IOException {
FileEntriesLayer.Builder builder =
FileEntriesLayer.builder().setName(LayerType.EXTRA_FILES.getName());
... | @@ -64,33 +69,40 @@ public static FileEntriesLayer extraDirectoryLayerConfiguration(
FileSystems.getDefault().getPathMatcher("glob:" + entry.getKey()), entry.getValue());
}
- new DirectoryWalker(sourceDirectory)
- .filterRoot()
- .walk(
- localPath -> {
- Absol... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java | 26 | Java | 0.357 | question | 74 | 51 | 51 | false | <includes> and <excludes> filtering feature for extraDirectories | 3,173 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelper.java
PR Title: <includes> and <excludes> filtering feature for extraDirectories
BEFORE CODE: List<String> excludes,
Map<String, FilePermissions> ext... | I'm probably missing something here, why is the `reduce` step needed here? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
(ignored1, ignored2) -> Instant.EPOCH);
assertExtractionPathsUnordered(
Arrays.asList("/a", "/a/b", "/a/b/bar", "/c", "/c/cat", "/foo"),
fileEntriesLayer.getEntries());
Map<AbsoluteUnixPath, FilePermissions> expectedPermissions =
ImmutableMap.<AbsoluteUnixPath, FilePermissio... | ah so excludes takes precedence? | AbsoluteUnixPath.get("/"),
Collections.emptyList(),
Arrays.asList("**/bar", "**/*a*"),
Collections.emptyMap(),
(ignored1, ignored2) -> Instant.EPOCH);
assertThat(layerConfiguration.getEntries())
.comparingElementsUsing(SOURCE_FILE_OF)
.cont... | @@ -92,17 +80,91 @@ public void testExtraDirectoryLayerConfiguration() throws URISyntaxException, IO
JavaContainerBuilderHelper.extraDirectoryLayerConfiguration(
extraFilesDirectory,
AbsoluteUnixPath.get("/"),
+ Collections.emptyList(),
+ Collections.emptyList(),... | jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelperTest.java | 26 | Java | 0.071 | question | 32 | 51 | 51 | false | <includes> and <excludes> filtering feature for extraDirectories | 3,173 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/JavaContainerBuilderHelperTest.java
PR Title: <includes> and <excludes> filtering feature for extraDirectories
BEFORE CODE: (ignored1, ignored2) -> Instant.EPOCH);
assertE... | ah so excludes takes precedence? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return new Command("docker", "run", "--rm", imageReference).run();
}
@Test
public void testExecute_simple()
throws VerificationException, IOException, InterruptedException, DigestException {
String targetImage = "simpleimage:maven" + System.nanoTime();
Assert.assertEquals(
"Hello, worl... | how about something like this?
```suggestion
// No "bar" or "*.txt" files. Only copies the following:
``` | return new Command("docker", "run", "--rm", imageReference).run();
}
@Test
public void testExecute_simple()
throws VerificationException, IOException, InterruptedException, DigestException {
String targetImage = "simpleimage:maven" + System.nanoTime();
Assert.assertEquals(
"Hello, worl... | @@ -99,12 +101,28 @@ public void testExecute_simple()
Assert.assertEquals(
"Hello, world. An argument.\n1970-01-01T00:00:01Z\nrw-r--r--\nrw-r--r--\nfoo\ncat\n"
+ "1970-01-01T00:00:01Z\n1970-01-01T00:00:01Z\n",
- buildToDockerDaemonAndRun(simpleTestProject.getProjectRoot(), targetImage)... | jib-maven-plugin/src/integration-test/java/com/google/cloud/tools/jib/maven/BuildDockerMojoIntegrationTest.java | 26 | Java | 0.714 | question | 115 | 51 | 51 | false | Add CHANGELOG and integration tests for extra directories filtering | 3,176 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/integration-test/java/com/google/cloud/tools/jib/maven/BuildDockerMojoIntegrationTest.java
PR Title: Add CHANGELOG and integration tests for extra directories filtering
BEFORE CODE: return new Command("docker", "run", "--rm", imageRefer... | how about something like this?
```suggestion
// No "bar" or "*.txt" files. Only copies the following:
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
testWebServer = new TestWebServer(false, Collections.singletonList(response), 1);
configDir = temporaryFolder.getRoot().toPath();
}
@After
public void tearDown() throws IOException {
testWebServer.close();
}
@Test
public void testPerformUpdateCheck_newVersionFound() throws IOException {
In... | Truth has `assertThat(Instant)`, so you can probably do like `assertThat(modifiedTime).isAfter(before)` or something like that. | testWebServer = new TestWebServer(false, Collections.singletonList(response), 1);
configDir = temporaryFolder.getRoot().toPath();
}
@After
public void tearDown() throws IOException {
testWebServer.close();
}
@Test
public void testPerformUpdateCheck_newVersionFound() throws IOException {
In... | @@ -74,16 +74,16 @@ public void testPerformUpdateCheck_newVersionFound() throws IOException {
Optional<String> message =
UpdateChecker.performUpdateCheck(
configDir, "1.0.2", testWebServer.getEndpoint(), "tool name", ignored -> {});
- Assert.assertTrue(testWebServer.getInputRead().contains... | jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/UpdateCheckerTest.java | 26 | Java | 0.5 | suggestion | 127 | 51 | 51 | false | Migrate UpdateChecker tests to Truth | 3,177 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/UpdateCheckerTest.java
PR Title: Migrate UpdateChecker tests to Truth
BEFORE CODE: testWebServer = new TestWebServer(false, Collections.singletonList(response), 1);
configDir = te... | Truth has `assertThat(Instant)`, so you can probably do like `assertThat(modifiedTime).isAfter(before)` or something like that. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
try (TestWebServer server = new TestWebServer(false, Collections.singletonList(response), 1)) {
setupLastUpdateCheck();
Optional<String> message =
UpdateChecker.performUpdateCheck(
configDir, "1.0.2", server.getEndpoint(), "tool name", ignored -> {});
assertThat(message)
... | There are more instances of this in this PR. | try (TestWebServer server = new TestWebServer(false, Collections.singletonList(response), 1)) {
setupLastUpdateCheck();
Optional<String> message =
UpdateChecker.performUpdateCheck(
configDir, "1.0.2", server.getEndpoint(), "tool name", ignored -> {});
assertThat(message)
... | @@ -111,12 +110,13 @@ public void testPerformUpdateCheck_onLatest() throws IOException {
Optional<String> message =
UpdateChecker.performUpdateCheck(
configDir, "2.0.0", testWebServer.getEndpoint(), "tool name", ignored -> {});
- Assert.assertFalse(message.isPresent());
+
+ assertThat(m... | jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/UpdateCheckerTest.java | 26 | Java | 0.071 | suggestion | 44 | 51 | 51 | false | Migrate UpdateChecker tests to Truth | 3,177 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/UpdateCheckerTest.java
PR Title: Migrate UpdateChecker tests to Truth
BEFORE CODE: try (TestWebServer server = new TestWebServer(false, Collections.singletonList(response), 1)) {
... | There are more instances of this in this PR. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/**
* Asserts that the test project build output indicates a success.
*
* @param buildResult the builds results of the project under test
* @param taskName the name of the Jib task that was run
* @param successMessage a Jib-specific success message to check for
*/
static void assertBuildSuccess(B... | Let's make the name of this helper more descriptive? | }
/**
* Asserts that the test project build output indicates a success.
*
* @param buildResult the builds results of the project under test
* @param taskName the name of the Jib task that was run
* @param successMessage a Jib-specific success message to check for
*/
static void assertBuildSucce... | @@ -181,20 +183,10 @@ static void assertBuildSuccess(BuildResult buildResult, String taskName, String
MatcherAssert.assertThat(buildResult.getOutput(), CoreMatchers.containsString(successMessage));
}
- static void assertSimpleCreationTimeIsEqual(Instant match, String imageReference)
- throws IOException... | jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java | 26 | Java | 0.214 | refactor | 52 | 51 | 51 | false | Cleanups and fixes | 3,178 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java
PR Title: Cleanups and fixes
BEFORE CODE:
/**
* Asserts that the test project build output indicates a success.
*
* @param buildResult the builds results ... | Let's make the name of this helper more descriptive? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
*
* @param buildResult the builds results of the project under test
* @param taskName the name of the Jib task that was run
* @param successMessage a Jib-specific success message to check for
*/
static void assertBuildSuccess(BuildResult buildResult, String taskName, String successMessage) {
BuildT... | hm how about `assertThatExpectedImageDigestAndIdReturned`? |
/**
* Asserts that the test project build output indicates a success.
*
* @param buildResult the builds results of the project under test
* @param taskName the name of the Jib task that was run
* @param successMessage a Jib-specific success message to check for
*/
static void assertBuildSuccess(B... | @@ -189,7 +190,8 @@ static Instant getCreationTime(String imageReference) throws IOException, Interr
return Instant.parse(inspect);
}
- static void assertImageDigestAndId(Path projectRoot) throws IOException, DigestException {
+ static void assertValidImageDigestAndIdOutputFiles(Path projectRoot) | jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java | 26 | Java | 0.357 | question | 58 | 51 | 51 | false | Cleanups and fixes | 3,178 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/integration-test/java/com/google/cloud/tools/jib/gradle/JibRunHelper.java
PR Title: Cleanups and fixes
BEFORE CODE: *
* @param buildResult the builds results of the project under test
* @param taskName the name of the Jib task that... | hm how about `assertThatExpectedImageDigestAndIdReturned`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Hidden debug parameters
@CommandLine.Option(names = "--stacktrace", hidden = true, scope = CommandLine.ScopeType.INHERIT)
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean stacktrace;
@CommandLine.Option(
names = "--http-trace",
hidden = true,
arity = "0..1",
... | Why not accepting the whole path but a directory? I think it can be restrictive to some users who want to have a different name.
And probably it should have `scope = CommandLine.ScopeType.INHERIT` like others? | // Hidden debug parameters
@CommandLine.Option(names = "--stacktrace", hidden = true, scope = CommandLine.ScopeType.INHERIT)
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean stacktrace;
@CommandLine.Option(
names = "--http-trace",
hidden = true,
arity = "0..1",
... | @@ -244,6 +244,15 @@
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean serialize;
+ @CommandLine.Option(
+ names = "--image-json",
+ paramLabel = "<path-to-json>",
+ description =
+ "A path to the destination directory of jib-image.json. If provided, image det... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonCliOptions.java | 26 | Java | 0.786 | question | 212 | 51 | 51 | false | [jib-cli] Add option to create an output JSON file that contains image metadata for the built image | 3,187 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonCliOptions.java
PR Title: [jib-cli] Add option to create an output JSON file that contains image metadata for the built image
BEFORE CODE: // Hidden debug parameters
@CommandLine.Option(names = "--st... | Why not accepting the whole path but a directory? I think it can be restrictive to some users who want to have a different name.
And probably it should have `scope = CommandLine.ScopeType.INHERIT` like others? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@SuppressWarnings("NullAway.Init") // initialized by picocli
private ConsoleOutput consoleOutput;
// Hidden debug parameters
@CommandLine.Option(names = "--stacktrace", hidden = true, scope = CommandLine.ScopeType.INHERIT)
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean stacktr... | What do you think of `--result-json`? | @SuppressWarnings("NullAway.Init") // initialized by picocli
private ConsoleOutput consoleOutput;
// Hidden debug parameters
@CommandLine.Option(names = "--stacktrace", hidden = true, scope = CommandLine.ScopeType.INHERIT)
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean stacktr... | @@ -244,6 +244,15 @@
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean serialize;
+ @CommandLine.Option(
+ names = "--image-json", | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonCliOptions.java | 26 | Java | 0.214 | question | 37 | 51 | 51 | false | [jib-cli] Add option to create an output JSON file that contains image metadata for the built image | 3,187 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonCliOptions.java
PR Title: [jib-cli] Add option to create an output JSON file that contains image metadata for the built image
BEFORE CODE: @SuppressWarnings("NullAway.Init") // initialized by picocli
... | What do you think of `--result-json`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
consoleLogger.log(
LogEvent.Level.ERROR,
"\u001B[31;1m"
+ exception.getClass().getName()
+ ": "
+ exception.getMessage()
+ "\u001B[0m");
}
/**
* Writes image details (imageId, digest, tags, etc.) to a json file (jib-image.json), if the
... | It doesn't fail if the file already exists? | }
consoleLogger.log(
LogEvent.Level.ERROR,
"\u001B[31;1m"
+ exception.getClass().getName()
+ ": "
+ exception.getMessage()
+ "\u001B[0m");
}
/**
* Writes image details (imageId, digest, tags, etc.) to a json file, if the path to the json i... | @@ -67,6 +74,24 @@ static void logTerminatingException(
+ "\u001B[0m");
}
+ /**
+ * Writes image details (imageId, digest, tags, etc.) to a json file (jib-image.json), if the
+ * destination of the json is provided.
+ *
+ * @param imageJsonOutputPath optional path to jib-image.json (for examp... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java | 26 | Java | 0.071 | bug | 43 | 43 | 43 | false | [jib-cli] Add option to create an output JSON file that contains image metadata for the built image | 3,187 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java
PR Title: [jib-cli] Add option to create an output JSON file that contains image metadata for the built image
BEFORE CODE: }
consoleLogger.log(
LogEvent.Level.ERROR,
"\u001... | It doesn't fail if the file already exists? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
@Test
public void testLogTerminatingException_stackTrace() {
ConsoleLogger logger = mock(ConsoleLogger.class);
JibCli.logTerminatingException(logger, new IOException("test error message"), true);
String stackTraceLine =
"at com.google.cloud.tools.jib.cli.JibCliTest.testLogTerminatingExcept... | `newFile()` creates a file, so
`temporaryFolder.getRoot().toPath().resolve(...)`. | }
@Test
public void testLogTerminatingException_stackTrace() {
ConsoleLogger logger = mock(ConsoleLogger.class);
JibCli.logTerminatingException(logger, new IOException("test error message"), true);
String stackTraceLine =
"at com.google.cloud.tools.jib.cli.JibCliTest.testLogTerminatingExcept... | @@ -68,4 +91,26 @@ public void testLogTerminatingException_stackTrace() {
.log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
verifyNoMoreInteractions(logger);
}
+
+ @Test
+ public void testWriteImageJson()
+ throws InvalidImageReferenceException, IOExcept... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java | 26 | Java | 0.357 | suggestion | 84 | 38 | 38 | false | [jib-cli] Add option to create an output JSON file that contains image metadata for the built image | 3,187 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java
PR Title: [jib-cli] Add option to create an output JSON file that contains image metadata for the built image
BEFORE CODE: }
@Test
public void testLogTerminatingException_stackTrace() {
... | `newFile()` creates a file, so
`temporaryFolder.getRoot().toPath().resolve(...)`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@CommandLine.Option(names = "--stacktrace", hidden = true, scope = CommandLine.ScopeType.INHERIT)
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean stacktrace;
@CommandLine.Option(
names = "--http-trace",
hidden = true,
arity = "0..1",
defaultValue = "off",
... | Nit: should this be
```suggestion
"path to the json file that should contain image metadata (for example, digest, id and tags) after build is"
+ "complete")
```
? | @CommandLine.Option(names = "--stacktrace", hidden = true, scope = CommandLine.ScopeType.INHERIT)
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean stacktrace;
@CommandLine.Option(
names = "--http-trace",
hidden = true,
arity = "0..1",
defaultValue = "off",
... | @@ -244,6 +244,15 @@
@SuppressWarnings("NullAway.Init") // initialized by picocli
private boolean serialize;
+ @CommandLine.Option(
+ names = "--image-metadata-out",
+ paramLabel = "<path-to-json>",
+ description =
+ "A path to the json file that should contain image metadata (for examp... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonCliOptions.java | 26 | Java | 0.786 | question | 191 | 51 | 51 | false | [jib-cli] Add option to create an output JSON file that contains image metadata for the built image | 3,187 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonCliOptions.java
PR Title: [jib-cli] Add option to create an output JSON file that contains image metadata for the built image
BEFORE CODE: @CommandLine.Option(names = "--stacktrace", hidden = true, sco... | Nit: should this be
```suggestion
"path to the json file that should contain image metadata (for example, digest, id and tags) after build is"
+ "complete")
```
? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"jib", new String(ByteStreams.toByteArray(tarArchiveInputStream), StandardCharsets.UTF_8));
Assert.assertNull(tarArchiveInputStream.getNextTarEntry());
}
@Test
public void testToBlob_modificationTime() throws IOException {
testTarStreamBuilder.addByteEntry(
"foo".getBytes(StandardCharset... | let's initialize all the `TarArchiveEntry headerFile` variables in the beginning? To keep the "arrange" and "assert" blocks separate. | "jib", new String(ByteStreams.toByteArray(tarArchiveInputStream), StandardCharsets.UTF_8));
Assert.assertNull(tarArchiveInputStream.getNextTarEntry());
}
@Test
public void testToBlob_modificationTime() throws IOException {
testTarStreamBuilder.addByteEntry(
"foo".getBytes(StandardCharset... | @@ -130,17 +127,40 @@ public void testToBlob_multiByte() throws IOException {
Assert.assertEquals("crepecake", headerFile.getName());
Assert.assertEquals(
"asdf", new String(ByteStreams.toByteArray(tarArchiveInputStream), StandardCharsets.UTF_8));
- Assert.assertEquals(timeFromTarArchiveEntry, hea... | jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarStreamBuilderTest.java | 26 | Java | 0.5 | suggestion | 135 | 51 | 51 | false | CHANGELOG for reproducible buildTar change / refactor tests | 3,211 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarStreamBuilderTest.java
PR Title: CHANGELOG for reproducible buildTar change / refactor tests
BEFORE CODE: "jib", new String(ByteStreams.toByteArray(tarArchiveInputStream), StandardCharsets.UTF_8));... | let's initialize all the `TarArchiveEntry headerFile` variables in the beginning? To keep the "arrange" and "assert" blocks separate. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return ConfigurationPropertyValidator.parseListProperty(
System.getProperty(PropertyNames.CONTAINER_VOLUMES));
}
return volumes;
}
public void setVolumes(List<String> volumes) {
this.volumes = volumes;
}
@Input
@Optional
public Map<String, String> getLabels() {
if (System.g... | We should do this in the new way like [this](https://github.com/GoogleContainerTools/jib/blob/026a263b22b7265ddb5323ac74351c99486cad21/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java#L234-L242) (#3034 and [#3121](https://github.com/GoogleContainerTools/jib/pull/3121/files#diff-ec1f44... | System.getProperty(PropertyNames.CONTAINER_VOLUMES));
}
return volumes;
}
public void setVolumes(List<String> volumes) {
this.volumes = volumes;
}
@Input
@Optional
public MapProperty<String, String> getLabels() {
String labelsProperty = System.getProperty(PropertyNames.CONTAINER_... | @@ -200,11 +209,15 @@ public void setVolumes(List<String> volumes) {
return ConfigurationPropertyValidator.parseMapProperty(
System.getProperty(PropertyNames.CONTAINER_LABELS));
}
- return labels;
+ return labels.get();
}
public void setLabels(Map<String, String> labels) {
- this... | jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/ContainerParameters.java | 26 | Java | 0.643 | suggestion | 719 | 51 | 51 | false | Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094) | 3,242 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | NaitYoussef | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/ContainerParameters.java
PR Title: Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094)
BEFORE CODE: return ConfigurationPropertyValidator.parseListPro... | We should do this in the new way like [this](https://github.com/GoogleContainerTools/jib/blob/026a263b22b7265ddb5323ac74351c99486cad21/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/JibExtension.java#L234-L242) (#3034 and [#3121](https://github.com/GoogleContainerTools/jib/pull/3121/files#diff-ec1f44... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public void testToTags_containsNullTag() {
TargetImageParameters testToParameters = generateTargetImageParametersWithTags(null, "tag1");
Exception exception =
assertThrows(IllegalArgumentException.class, () -> testToParameters.getTags());
assertThat(exception).hasMessageThat().isEqualTo("jib.to.ta... | Checking this seems meaningful. Maybe this can be
```
assertThat(testJibExtension.getContainer().getLabels().get()).isEmpty();
``` | public void testToTags_containsNullTag() {
TargetImageParameters testToParameters = generateTargetImageParametersWithTags(null, "tag1");
Exception exception =
assertThrows(IllegalArgumentException.class, () -> testToParameters.getTags());
assertThat(exception).hasMessageThat().isEqualTo("jib.to.ta... | @@ -140,7 +140,6 @@ public void testContainer() {
assertThat(testJibExtension.getContainer().getArgs()).isNull();
assertThat(testJibExtension.getContainer().getFormat()).isSameInstanceAs(ImageFormat.Docker);
assertThat(testJibExtension.getContainer().getPorts()).isEmpty();
- assertThat(testJibExtensio... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java | 26 | Java | 0.714 | suggestion | 133 | 51 | 51 | false | Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094) | 3,242 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | NaitYoussef | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java
PR Title: Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094)
BEFORE CODE: public void testToTags_containsNullTag() {
TargetImag... | Checking this seems meaningful. Maybe this can be
```
assertThat(testJibExtension.getContainer().getLabels().get()).isEmpty();
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public void testContainer() {
assertThat(testJibExtension.getContainer().getJvmFlags()).isEmpty();
assertThat(testJibExtension.getContainer().getEnvironment()).isEmpty();
assertThat(testJibExtension.getContainer().getExtraClasspath()).isEmpty();
assertThat(testJibExtension.getContainer().getExpandClas... | Maybe this can be
```
container.getLabels().set(...)
```
? Then I guess we can keep the `assertThat()` below that you removed. | public void testContainer() {
assertThat(testJibExtension.getContainer().getJvmFlags()).isEmpty();
assertThat(testJibExtension.getContainer().getEnvironment()).isEmpty();
assertThat(testJibExtension.getContainer().getExtraClasspath()).isEmpty();
assertThat(testJibExtension.getContainer().getExpandClas... | @@ -156,7 +155,6 @@ public void testContainer() {
container.setMainClass("mainClass");
container.setArgs(Arrays.asList("arg1", "arg2", "arg3"));
container.setPorts(Arrays.asList("1000", "2000-2010", "3000"));
- container.setLabels(ImmutableMap.of("label1", "value1", "label2", "... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java | 26 | Java | 0.786 | suggestion | 130 | 51 | 51 | false | Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094) | 3,242 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | NaitYoussef | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java
PR Title: Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094)
BEFORE CODE: public void testContainer() {
assertThat(testJibExten... | Maybe this can be
```
container.getLabels().set(...)
```
? Then I guess we can keep the `assertThat()` below that you removed. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
System.setProperty("jib.container.entrypoint", "entry1,entry2,entry3");
assertThat(testJibExtension.getContainer().getEntrypoint())
.containsExactly("entry1", "entry2", "entry3")
.inOrder();
System.setProperty("jib.container.environment", "env1=val1,env2=val2");
assertThat(testJibExtensi... | I think we don't need additional `assertThat()` followed by `System.clearProperty()`. I'd revert the change here. | .inOrder();
System.setProperty("jib.container.entrypoint", "entry1,entry2,entry3");
assertThat(testJibExtension.getContainer().getEntrypoint())
.containsExactly("entry1", "entry2", "entry3")
.inOrder();
System.setProperty("jib.container.environment", "env1=val1,env2=val2");
asser... | @@ -379,7 +374,11 @@ public void testProperties() {
.containsExactly("flag1", "flag2", "flag3")
.inOrder();
System.setProperty("jib.container.labels", "label1=val1,label2=val2");
- assertThat(testJibExtension.getContainer().getLabels())
+ assertThat(testJibExtension.getContainer().getLabels... | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java | 26 | Java | 0.571 | suggestion | 113 | 51 | 51 | false | Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094) | 3,242 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | NaitYoussef | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java
PR Title: Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094)
BEFORE CODE: System.setProperty("jib.container.entrypoint", "entry1,... | I think we don't need additional `assertThat()` followed by `System.clearProperty()`. I'd revert the change here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/*
* Copyright 2018 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | `internal` concerns me. Let's do this:
```diff
@@ -21,16 +21,23 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import java.nio.file.Paths;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import org.gradl... | /*
* Copyright 2018 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | @@ -23,6 +23,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import org.gradle.api.internal.provider.DefaultMapProperty; | jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleRawConfigurationTest.java | 26 | Java | 0.857 | suggestion | 1,889 | 51 | 51 | false | Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094) | 3,242 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | NaitYoussef | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleRawConfigurationTest.java
PR Title: Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094)
BEFORE CODE: /*
* Copyright 2018 Google LLC.
*
* Licensed u... | `internal` concerns me. Let's do this:
```diff
@@ -21,16 +21,23 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import java.nio.file.Paths;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import org.gradl... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public void setPorts(List<String> ports) {
this.ports = ports;
}
@Input
@Optional
public List<String> getVolumes() {
if (System.getProperty(PropertyNames.CONTAINER_VOLUMES) != null) {
return ConfigurationPropertyValidator.parseListProperty(
System.getProperty(PropertyNames.CONTAINER_V... | Sorry, this was missing in #3094. (I updated the issue to reflect this information.) We should call `.set()` only when the values differ. Using `.equals()` will do.
```suggestion
if (!parsedLabels.equals(labels.get()) {
labels.set(parsedLabels);
}
``` | public void setPorts(List<String> ports) {
this.ports = ports;
}
@Input
@Optional
public List<String> getVolumes() {
if (System.getProperty(PropertyNames.CONTAINER_VOLUMES) != null) {
return ConfigurationPropertyValidator.parseListProperty(
System.getProperty(PropertyNames.CONTAINER_V... | @@ -195,18 +203,16 @@ public void setVolumes(List<String> volumes) {
@Input
@Optional
- public Map<String, String> getLabels() {
- if (System.getProperty(PropertyNames.CONTAINER_LABELS) != null) {
- return ConfigurationPropertyValidator.parseMapProperty(
- System.getProperty(PropertyNames.CONT... | jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/ContainerParameters.java | 26 | Java | 0.857 | suggestion | 276 | 51 | 51 | false | Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094) | 3,242 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | NaitYoussef | Review this pull request change.
Language: Java
File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/ContainerParameters.java
PR Title: Use Gradle Property and Provider to enable lazy evaluation for jib.container.labels (#3094)
BEFORE CODE: public void setPorts(List<String> ports) {
this.po... | Sorry, this was missing in #3094. (I updated the issue to reflect this information.) We should call `.set()` only when the values differ. Using `.equals()` will do.
```suggestion
if (!parsedLabels.equals(labels.get()) {
labels.set(parsedLabels);
}
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import com.google.cloud.tools.jib.cli.ArtifactProcessor;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.List;
public class WarFiles {
/**
* Generates a {@link JibContainerBuilder} from contents of a WAR file.
*
* @param processor artifact processor
* @return... | Is this going to be expanded a lot? (I guess yes.) Otherwise, this could be
```java
return Jib.from("jetty")
.setEntrypoint(processor....)
.setFileEntriesLayers(processor.createLayers());
``` | import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.List;
public class WarFiles {
/**
* Generates a {@link JibContainerBuilder} from contents of a WAR file.
*
* @param processor artifact processor
* @return JibContainerBuilder
* @throws IOException if I/O erro... | @@ -0,0 +1,50 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by ... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/war/WarFiles.java | 26 | Java | 0.857 | question | 204 | 29 | 27 | false | Implement class to create JibContainerBuilder from the contents of a WAR file | 3,248 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/war/WarFiles.java
PR Title: Implement class to create JibContainerBuilder from the contents of a WAR file
BEFORE CODE: import com.google.cloud.tools.jib.cli.ArtifactProcessor;
import com.google.common.collect.... | Is this going to be expanded a lot? (I guess yes.) Otherwise, this could be
```java
return Jib.from("jetty")
.setEntrypoint(processor....)
.setFileEntriesLayers(processor.createLayers());
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import java.nio.file.Paths;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
/** Tests for {@link WarFiles}. */
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@M... | ```suggestion
when(mockStandardWarExplodedProcessor.computeEntrypoint(anyList()))
``` | import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
/** Tests for {@link WarFiles}. */
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@Mock priva... | @@ -0,0 +1,75 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by ... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java | 26 | Java | 0.571 | suggestion | 91 | 48 | 49 | false | Implement class to create JibContainerBuilder from the contents of a WAR file | 3,248 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java
PR Title: Implement class to create JibContainerBuilder from the contents of a WAR file
BEFORE CODE: import java.nio.file.Paths;
import java.util.Arrays;
import org.junit.Test;
import org... | ```suggestion
when(mockStandardWarExplodedProcessor.computeEntrypoint(anyList()))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
/** Tests for {@link WarFiles}. */
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@Mock private StandardWarExplo... | Maybe just for consistency, `Arrays.asList()` instead of `ImmutableList.of()`? | import java.nio.file.Paths;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
/** Tests for {@link WarFiles}. */
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@Mock private StandardWarExplodedProces... | @@ -0,0 +1,75 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by ... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java | 26 | Java | 0.429 | question | 78 | 47 | 48 | false | Implement class to create JibContainerBuilder from the contents of a WAR file | 3,248 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java
PR Title: Implement class to create JibContainerBuilder from the contents of a WAR file
BEFORE CODE: import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
impor... | Maybe just for consistency, `Arrays.asList()` instead of `ImmutableList.of()`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@Mock private StandardWarExplodedProcessor mockStandardWarExplodedProcessor;
@Test
public void testToJibContainerBuilder_explodedStandard_basicInfo()
throws IOException, InvalidImageReferenceException {
FileEntriesLayer layer =
Fil... | Why not `.containersExactly(...).inOrder()`? | @RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@Mock private StandardWarExplodedProcessor mockStandardWarExplodedProcessor;
@Test
public void testToJibContainerBuilder_explodedStandard_basicInfo()
throws IOException, InvalidImageReferenceException {
FileEntriesLayer layer =
Fil... | @@ -0,0 +1,75 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by ... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java | 26 | Java | 0.214 | question | 44 | 39 | 40 | false | Implement class to create JibContainerBuilder from the contents of a WAR file | 3,248 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java
PR Title: Implement class to create JibContainerBuilder from the contents of a WAR file
BEFORE CODE: @RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {
@Mock private Standa... | Why not `.containersExactly(...).inOrder()`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public class WarFilesTest {
@Mock private StandardWarExplodedProcessor mockStandardWarExplodedProcessor;
@Test
public void testToJibContainerBuilder_explodedStandard_basicInfo()
throws IOException, InvalidImageReferenceException {
FileEntriesLayer layer =
FileEntriesLayer.builder()
... | Doesn't it have `assertThat(...).isSize(1)` or something like that? | public class WarFilesTest {
@Mock private StandardWarExplodedProcessor mockStandardWarExplodedProcessor;
@Test
public void testToJibContainerBuilder_explodedStandard_basicInfo()
throws IOException, InvalidImageReferenceException {
FileEntriesLayer layer =
FileEntriesLayer.builder()
... | @@ -0,0 +1,75 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by ... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java | 26 | Java | 0.357 | question | 67 | 38 | 39 | false | Implement class to create JibContainerBuilder from the contents of a WAR file | 3,248 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java
PR Title: Implement class to create JibContainerBuilder from the contents of a WAR file
BEFORE CODE: public class WarFilesTest {
@Mock private StandardWarExplodedProcessor mockStandard... | Doesn't it have `assertThat(...).isSize(1)` or something like that? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
throw new IllegalStateException("unknown containerizing mode: " + mode);
}
if (projectProperties.getMajorJavaVersion() >= 9
|| rawConfiguration.getExpandClasspathDependencies()) {
List<String> dependencies =
projectProperties
.getDependencies()
.strea... | Just a thought, can we call `MainClassResolver#resolveMainClass` only if the entrypoint is not defined? | throw new IllegalStateException("unknown containerizing mode: " + mode);
}
if (projectProperties.getMajorJavaVersion() >= 9
|| rawConfiguration.getExpandClasspathDependencies()) {
List<String> dependencies =
projectProperties
.getDependencies()
.strea... | @@ -632,9 +632,19 @@ static JavaContainerBuilder getJavaContainerBuilderWithBaseImage(
}
String classpathString = String.join(":", classpath);
- String mainClass =
- MainClassResolver.resolveMainClass(
- rawConfiguration.getMainClass().orElse(null), projectProperties);
+ String mainC... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java | 26 | Java | 0.5 | question | 103 | 51 | 51 | false | Don't fail on main class inference if custom entrypoint | 3,296 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
PR Title: Don't fail on main class inference if custom entrypoint
BEFORE CODE: throw new IllegalStateException("unknown containerizing mode: " + ... | Just a thought, can we call `MainClassResolver#resolveMainClass` only if the entrypoint is not defined? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for (ContainerizingMode containerizingMode : ContainerizingMode.values()) {
IOException thrownException =
Assert.assertThrows(
IOException.class,
() ->
mavenProjectProperties.createJibContainerBuilder(
mockJavaContainerBuilder, con... | ```suggestion
assertThrows(
``` |
for (ContainerizingMode containerizingMode : ContainerizingMode.values()) {
IOException thrownException =
assertThrows(
IOException.class,
() ->
mavenProjectProperties.createJibContainerBuilder(
mockJavaContainerBuilder, containeri... | @@ -570,6 +573,49 @@ public void testCreateContainerBuilder_noErrorIfWebInfLibDoesNotExist()
.isNotNull();
}
+ @Test
+ public void testCreateContainerBuilder_exceptionMessageHasPackageSuggestionIfProjectIsWar()
+ throws IOException {
+ String expectedMessage =
+ "Obtaining project build o... | jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesTest.java | 26 | Java | 0.429 | suggestion | 41 | 51 | 51 | false | Add packaging condition to format exception message correctly in MavenProjectProperties#createJibContainerBuilder | 3,306 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | JacekDuszenko | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesTest.java
PR Title: Add packaging condition to format exception message correctly in MavenProjectProperties#createJibContainerBuilder
BEFORE CODE:
for (ContainerizingMode ... | ```suggestion
assertThrows(
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
() ->
mavenProjectProperties.createJibContainerBuilder(
mockJavaContainerBuilder, containerizingMode));
Assert.assertEquals(thrownException.getMessage(), expectedMessage);
}
}
@Test
public void
testCreateContainerBuilder_exceptionMessageHasCom... | ```suggestion
assertThat(thrownException).hasMessageThat().isEqualTo(expectedMessage);
``` | () ->
mavenProjectProperties.createJibContainerBuilder(
mockJavaContainerBuilder, containerizingMode));
assertThat(thrownException).hasMessageThat().isEqualTo(expectedMessage);
}
}
@Test
public void
testCreateContainerBuilder_exceptionMessageH... | @@ -570,6 +573,49 @@ public void testCreateContainerBuilder_noErrorIfWebInfLibDoesNotExist()
.isNotNull();
}
+ @Test
+ public void testCreateContainerBuilder_exceptionMessageHasPackageSuggestionIfProjectIsWar()
+ throws IOException {
+ String expectedMessage =
+ "Obtaining project build o... | jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesTest.java | 26 | Java | 0.714 | suggestion | 96 | 51 | 51 | false | Add packaging condition to format exception message correctly in MavenProjectProperties#createJibContainerBuilder | 3,306 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | JacekDuszenko | Review this pull request change.
Language: Java
File: jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesTest.java
PR Title: Add packaging condition to format exception message correctly in MavenProjectProperties#createJibContainerBuilder
BEFORE CODE: () ->
... | ```suggestion
assertThat(thrownException).hasMessageThat().isEqualTo(expectedMessage);
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
public List<String> getEntrypoint() {
return entrypoint;
}
/**
* Returns {@link Instant} representing creation time of container.
*
* @return an optional creation time
*/
public Optional<Instant> getCreationTime() {
if (creationTime != null) {
return Optional.of(Instants.fromMillisOr... | What if we make this non-static and examine the `from` field of the class? |
public List<String> getEntrypoint() {
return entrypoint;
}
/**
* Returns {@link Instant} representing creation time of container.
*
* @return an optional creation time
*/
public Optional<Instant> getCreationTime() {
if (creationTime != null) {
return Optional.of(Instants.fromMillisOr... | @@ -176,4 +178,21 @@
}
return Optional.empty();
}
+
+ /**
+ * Returns {@code true} if the user-specified base image is jetty or if a custom base image is not
+ * specified.
+ *
+ * @param baseImage the base image
+ * @return a boolean
+ * @throws InvalidImageReferenceException if image referen... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonContainerConfigCliOptions.java | 26 | Java | 0.357 | question | 74 | 35 | 34 | false | Remove duplicate code from Jib CLI | 3,310 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonContainerConfigCliOptions.java
PR Title: Remove duplicate code from Jib CLI
BEFORE CODE:
public List<String> getEntrypoint() {
return entrypoint;
}
/**
* Returns {@link Instant} representi... | What if we make this non-static and examine the `from` field of the class? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
public List<String> getEntrypoint() {
return entrypoint;
}
/**
* Returns {@link Instant} representing creation time of container.
*
* @return an optional creation time
*/
public Optional<Instant> getCreationTime() {
if (creationTime != null) {
return Optional.of(Instants.fromMill... | Sorry, missed this. I think the name should be `isJettyBaseImage`. Otherwise, it's confusing. | }
public List<String> getEntrypoint() {
return entrypoint;
}
/**
* Returns {@link Instant} representing creation time of container.
*
* @return an optional creation time
*/
public Optional<Instant> getCreationTime() {
if (creationTime != null) {
return Optional.of(Instants.fromMill... | @@ -176,4 +178,20 @@
}
return Optional.empty();
}
+
+ /**
+ * Returns {@code true} if the user-specified base image is jetty or if a custom base image is not
+ * specified.
+ *
+ * @return a boolean
+ * @throws InvalidImageReferenceException if image reference is invalid
+ */
+ public Boolean... | jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonContainerConfigCliOptions.java | 26 | Java | 0.429 | suggestion | 93 | 35 | 35 | false | Remove duplicate code from Jib CLI | 3,310 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CommonContainerConfigCliOptions.java
PR Title: Remove duplicate code from Jib CLI
BEFORE CODE: }
public List<String> getEntrypoint() {
return entrypoint;
}
/**
* Returns {@link Instant} repres... | Sorry, missed this. I think the name should be `isJettyBaseImage`. Otherwise, it's confusing. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
assertThat(buildPlan.getExposedPorts()).isEqualTo(ImmutableSet.of(Port.udp(123)));
assertThat(buildPlan.getVolumes())
.isEqualTo(
ImmutableSet.of(AbsoluteUnixPath.get("/volume1"), AbsoluteUnixPath.get("/volume2")));
assertThat(buildPlan.getEnvironment()).isEqualTo(ImmutableMap.of("key1",... | Hmm... does it make sense that the entrypoint is null when `isJetty()` from the mock is returning true? | assertThat(buildPlan.getExposedPorts()).isEqualTo(ImmutableSet.of(Port.udp(123)));
assertThat(buildPlan.getVolumes())
.isEqualTo(
ImmutableSet.of(AbsoluteUnixPath.get("/volume1"), AbsoluteUnixPath.get("/volume2")));
assertThat(buildPlan.getEnvironment()).isEqualTo(ImmutableMap.of("key1",... | @@ -144,29 +143,9 @@ public void testToJibContainerBuilder_nonJettyBaseImageSpecifiedAndNoEntrypoint(
mockLogger);
ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();
- assertThat(buildPlan.getBaseImage()).isEqualTo("base-image");
assertThat(buildPlan.getEntrypoint()).isN... | jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java | 26 | Java | 0.643 | question | 103 | 42 | 43 | false | Remove duplicate code from Jib CLI | 3,310 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | mpeddada1 | Review this pull request change.
Language: Java
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java
PR Title: Remove duplicate code from Jib CLI
BEFORE CODE: assertThat(buildPlan.getExposedPorts()).isEqualTo(ImmutableSet.of(Port.udp(123)));
assertThat(buildPlan.getVolumes())
... | Hmm... does it make sense that the entrypoint is null when `isJetty()` from the mock is returning true? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
if (projectProperties.getMajorJavaVersion() >= 9
|| rawConfiguration.getExpandClasspathDependencies()) {
List<Path> jars = projectProperties.getDependencies();
List<String> duplicates =
jars.stream()
.map(path -> path.getFileName().toString())
.collec... | This situation is pretty rare but what if we end up with jars that are of the same size? How about we append incremented integers to jar name? Such as `jar-name-1.jar` and `jar-name-2.jar`. | }
if (projectProperties.getMajorJavaVersion() >= 9
|| rawConfiguration.getExpandClasspathDependencies()) {
List<Path> jars = projectProperties.getDependencies();
Map<String, Long> occurrences =
jars.stream()
.map(path -> path.getFileName().toString())
... | @@ -620,13 +621,27 @@ static JavaContainerBuilder getJavaContainerBuilderWithBaseImage(
if (projectProperties.getMajorJavaVersion() >= 9
|| rawConfiguration.getExpandClasspathDependencies()) {
- List<String> dependencies =
- projectProperties
- .getDependencies()
+ List<P... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java | 26 | Java | 0.5 | suggestion | 190 | 51 | 51 | false | Add jar size suffix to target dependency paths on image when dependency jars have same artifact ID and version | 3,336 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
PR Title: Add jar size suffix to target dependency paths on image when dependency jars have same artifact ID and version
BEFORE CODE: }
if (proj... | This situation is pretty rare but what if we end up with jars that are of the same size? How about we append incremented integers to jar name? Such as `jar-name-1.jar` and `jar-name-2.jar`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
: Arrays.asList("java", "-jar", "/usr/local/jetty/start.jar");
}
List<String> classpath = new ArrayList<>(rawExtraClasspath);
AbsoluteUnixPath appRoot = getAppRootChecked(rawConfiguration, projectProperties);
ContainerizingMode mode = getContainerizingModeChecked(rawConfiguration, projectProp... | nit: Maybe we could simplify the logic by put this under a separate variable (`occurrencesMap`)? | : Arrays.asList("java", "-jar", "/usr/local/jetty/start.jar");
}
List<String> classpath = new ArrayList<>(rawExtraClasspath);
AbsoluteUnixPath appRoot = getAppRootChecked(rawConfiguration, projectProperties);
ContainerizingMode mode = getContainerizingModeChecked(rawConfiguration, projectProp... | @@ -620,13 +621,27 @@ static JavaContainerBuilder getJavaContainerBuilderWithBaseImage(
if (projectProperties.getMajorJavaVersion() >= 9
|| rawConfiguration.getExpandClasspathDependencies()) {
- List<String> dependencies =
- projectProperties
- .getDependencies()
+ List<P... | jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java | 26 | Java | 0.429 | refactor | 96 | 51 | 51 | false | Add jar size suffix to target dependency paths on image when dependency jars have same artifact ID and version | 3,336 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
PR Title: Add jar size suffix to target dependency paths on image when dependency jars have same artifact ID and version
BEFORE CODE: : Arrays.... | nit: Maybe we could simplify the logic by put this under a separate variable (`occurrencesMap`)? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
package com.google.cloud.tools.jib.blob;
import com.google.cloud.tools.jib.hash.Digests;
import com.google.cloud.tools.jib.hash.WritableContents;
import java.io.IOException;
import java.io.OutputStream;
/** A {@link Blob} that holds {@link WritableContents}. */
class WritableContentsBlob implements Blob {
private... | This should be false. `WritableContents` can be any lambda and doesn't have a guarantee that they are retriable. In fact, blob pulls (which is reading HTTP response input stream) from a registry is routinely wrapped as `WritableContents`, and such a stream is not a retriable one. Actually, It is confusing at this level... |
package com.google.cloud.tools.jib.blob;
import com.google.cloud.tools.jib.hash.Digests;
import com.google.cloud.tools.jib.hash.WritableContents;
import java.io.IOException;
import java.io.OutputStream;
/** A {@link Blob} that holds {@link WritableContents}. */
class WritableContentsBlob implements Blob {
private... | @@ -34,4 +34,10 @@
public BlobDescriptor writeTo(OutputStream outputStream) throws IOException {
return Digests.computeDigest(writableContents, outputStream);
}
+
+ // in general it is since the underlying data is accessed in the lambda
+ @Override
+ public boolean isRetryable() {
+ return true; | jib-core/src/main/java/com/google/cloud/tools/jib/blob/WritableContentsBlob.java | 26 | Java | 0.643 | suggestion | 727 | 29 | 30 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/blob/WritableContentsBlob.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE:
package com.google.cloud.tools.jib.blob;
import com.google.cloud.tools.jib.hash.Digests;
import com.g... | This should be false. `WritableContents` can be any lambda and doesn't have a guarantee that they are retriable. In fact, blob pulls (which is reading HTTP response input stream) from a registry is routinely wrapped as `WritableContents`, and such a stream is not a retriable one. Actually, It is confusing at this level... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.tools.jib.blob;
import java.io.IOException;
import java.io.OutputStream;
/** Holds a BLOB source for writing to an {@link OutputStream}. */
public interface Blob {
/**
* Writes the BLOB... | In our codebase, there exists a hierarchy of layers (roughly divided into Java packages), and `com.google.cloud.tools.jib.blob` sits at the very bottom part of the hierarchy. We also maintain the hierarchy non-circular. Each layer should be insulated and should only know and use the abstractions established below its p... | * License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.tools.jib.blob;
import java.io.IOException;
import java.io.OutputStream;
/** Holds a BLOB source for writing to an {@link OutputStream}. */
public interface Blob {
/**
* Writes the BLOB... | @@ -30,4 +30,12 @@
* @throws IOException if writing the BLOB fails
*/
BlobDescriptor writeTo(OutputStream outputStream) throws IOException;
+
+ /**
+ * Enables to notify to the HTTP client if the underlying request can be retried.
+ * @return {@code true} if {@link #writeTo(OutputStream)} can be called ... | jib-core/src/main/java/com/google/cloud/tools/jib/blob/Blob.java | 26 | Java | 0.786 | refactor | 996 | 30 | 31 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/blob/Blob.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: * License for the specific language governing permissions and limitations under
* the License.
*/
package com.googl... | In our codebase, there exists a hierarchy of layers (roughly divided into Java packages), and `com.google.cloud.tools.jib.blob` sits at the very bottom part of the hierarchy. We also maintain the hierarchy non-circular. Each layer should be insulated and should only know and use the abstractions established below its p... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return Optional.empty(); // No history found. Should go for normal execution path.
}
}
private Response call(String httpMethod, URL url, Request request, HttpTransport httpTransport)
throws IOException {
boolean clearAuthorization = !isHttpsProtocol(url) && !sendAuthorizationOverHttp;
Ht... | I think the `else` branch can be debug (or removed).
```suggestion
logger.accept(LogEvent.warn(reqString + " failed due to IOException and will be retried"));
} else {
logger.accept(LogEvent.debug(reqString + " failed due to IOException and will NOT be retried"))... | Response response = call(httpMethod, toHttp(url), request, getHttpTransport(true));
failoverHistory.put(url.getHost() + ":" + url.getPort(), Failover.HTTP);
return response;
}
}
throw ex;
}
}
private Optional<Response> followFailoverHistory(String httpMethod, U... | @@ -312,6 +315,19 @@ private Response call(String httpMethod, URL url, Request request, HttpTransport
httpTransport
.createRequestFactory()
.buildRequest(httpMethod, new GenericUrl(url), request.getHttpContent())
+ .setIOExceptionHandler(new HttpBackOffIOExceptionHandler(ne... | jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java | 26 | Java | 1 | bug | 326 | 51 | 51 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: return Optional.empty(); // No history found. Should go for normal execution path.
}
}
p... | I think the `else` branch can be debug (or removed).
```suggestion
logger.accept(LogEvent.warn(reqString + " failed due to IOException and will be retried"));
} else {
logger.accept(LogEvent.debug(reqString + " failed due to IOException and will NOT be retried"))... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
throws IOException {
Preconditions.checkArgument(isHttpsProtocol(url));
switch (failoverHistory.getOrDefault(url.getHost() + ":" + url.getPort(), Failover.NONE)) {
case HTTP:
return Optional.of(call(httpMethod, toHttp(url), request, getHttpTransport(true)));
case INSECURE_HTTPS:
... | What's the maximum number of retries (and the maximum time) until this eventually gives up? We don't want for Jib to run for too long when it's not recoverable (e.g., server is down for a day). | // ConnectException for connection timeout. (Could be a JDK bug.) Note SocketTimeoutException
// does not extend ConnectException (or vice versa), and we want to be consistent to error out
// on timeouts: https://github.com/GoogleContainerTools/jib/issues/1895#issuecomment-527544094
if (ex.getMe... | @@ -312,6 +315,19 @@ private Response call(String httpMethod, URL url, Request request, HttpTransport
httpTransport
.createRequestFactory()
.buildRequest(httpMethod, new GenericUrl(url), request.getHttpContent())
+ .setIOExceptionHandler(new HttpBackOffIOExceptionHandler(ne... | jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java | 26 | Java | 0.357 | refactor | 193 | 51 | 51 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: throws IOException {
Preconditions.checkArgument(isHttpsProtocol(url));
switch (failoverHis... | What's the maximum number of retries (and the maximum time) until this eventually gives up? We don't want for Jib to run for too long when it's not recoverable (e.g., server is down for a day). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return Optional.of(call(httpMethod, toHttp(url), request, getHttpTransport(true)));
case INSECURE_HTTPS:
return Optional.of(call(httpMethod, url, request, getHttpTransport(false)));
default:
return Optional.empty(); // No history found. Should go for normal execution path.
}
}
... | nit per Google-style:
```suggestion
public boolean handleIOException(HttpRequest request, boolean supportsRetry) throws IOException {
boolean result = super.handleIOException(request, supportsRetry);
String requestUrl = request.getRequestMethod() + " " + request.getUrl(... | // Fall back to HTTP only if "url" had no port specified (i.e., we tried the default HTTPS
// port 443) and we could not connect to 443. It's worth trying port 80.
if (enableHttpAndInsecureFailover && isHttpsProtocol(url) && url.getPort() == -1) {
logHttpFailover(url);
Respon... | @@ -312,6 +315,19 @@ private Response call(String httpMethod, URL url, Request request, HttpTransport
httpTransport
.createRequestFactory()
.buildRequest(httpMethod, new GenericUrl(url), request.getHttpContent())
+ .setIOExceptionHandler(new HttpBackOffIOExceptionHandler(ne... | jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java | 26 | Java | 0.929 | suggestion | 327 | 51 | 51 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: return Optional.of(call(httpMethod, toHttp(url), request, getHttpTransport(true)));
case IN... | nit per Google-style:
```suggestion
public boolean handleIOException(HttpRequest request, boolean supportsRetry) throws IOException {
boolean result = super.handleIOException(request, supportsRetry);
String requestUrl = request.getRequestMethod() + " " + request.getUrl(... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"Cannot verify server at https://url:2. Attempting again with no TLS verification.");
}
@Test
public void testRetries() throws IOException {
final HttpServer server = HttpServer.create(new InetSocketAddress("localhost", 0), 64);
final AtomicReference<HttpHandler> current = new AtomicReference<>()... | I don't think this works as you intended. 123 actually causes IOException. OTOH, 400 works.
There are some minor style errors, and given above, I'd have the code to look like this:
```java
import static com.google.common.truth.Truth.assertThat;
public void testRetries() throws IOException {
HttpServer ser... | "Cannot verify server at https://url:2. Attempting again with no TLS verification.");
}
@Test
public void testRetries() throws IOException {
final HttpServer server = HttpServer.create(new InetSocketAddress("localhost", 0), 64);
final AtomicReference<HttpHandler> current = new AtomicReference<>()... | @@ -416,6 +425,55 @@ public void testFollowFailoverHistory_portsDifferent() throws IOException {
"Cannot verify server at https://url:2. Attempting again with no TLS verification.");
}
+ @Test
+ public void testRetries() throws IOException {
+ final HttpServer server = HttpServer.create(new InetSocke... | jib-core/src/test/java/com/google/cloud/tools/jib/http/FailoverHttpClientTest.java | 26 | Java | 1 | bug | 1,234 | 51 | 51 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/test/java/com/google/cloud/tools/jib/http/FailoverHttpClientTest.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: "Cannot verify server at https://url:2. Attempting again with no TLS verification.");
}
... | I don't think this works as you intended. 123 actually causes IOException. OTOH, 400 works.
There are some minor style errors, and given above, I'd have the code to look like this:
```java
import static com.google.common.truth.Truth.assertThat;
public void testRetries() throws IOException {
HttpServer ser... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
layerEntry.getSourceFile(), layerEntry.getExtractionPath().toString());
// Sets the entry's permissions by masking out the permission bits from the entry's mode (the
// lowest 9 bits) then using a bitwise OR to set them to the layerEntry's permissions.
entry.setMode((entry.getMode() & ~... | Just noticed that generally speaking `TarStreamBuilder::writeAsTarArchiveTo` is not retryable, as non-retryable `Blob`s [can be added](https://github.com/GoogleContainerTools/jib/blob/1fd6b62c90bb96a53fdc719265c4224157810361/jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java#L92) to it.
```sug... | layerEntry.getSourceFile(), layerEntry.getExtractionPath().toString());
// Sets the entry's permissions by masking out the permission bits from the entry's mode (the
// lowest 9 bits) then using a bitwise OR to set them to the layerEntry's permissions.
entry.setMode((entry.getMode() & ~... | @@ -176,6 +176,6 @@ public Blob build() throws IOException {
tarStreamBuilder.addTarArchiveEntry(entry);
}
- return Blobs.from(tarStreamBuilder::writeAsTarArchiveTo);
+ return Blobs.from(tarStreamBuilder::writeAsTarArchiveTo, true); | jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java | 26 | Java | 0.786 | suggestion | 402 | 29 | 29 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: layerEntry.getSourceFile(), layerEntry.getExtractionPath().toString());
// Se... | Just noticed that generally speaking `TarStreamBuilder::writeAsTarArchiveTo` is not retryable, as non-retryable `Blob`s [can be added](https://github.com/GoogleContainerTools/jib/blob/1fd6b62c90bb96a53fdc719265c4224157810361/jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java#L92) to it.
```sug... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarArchiveEntry}
*/
public void addTarArchiveEntry(TarArchiveEntry entry) {
archiveMap.put(
entry, entry.isFile() ? Blobs.from(entry.getPath()) : Blobs.from(ignored -> {}, true));
}
/**
* Adds... | I think true. (`contents` isn't totally immutable as it's a reference to an array, but this is implied and assumed in the existing code.)
```suggestion
archiveMap.put(entry, Blobs.from(outputStream -> outputStream.write(contents), true));
``` | }
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarArchiveEntry}
*/
public void addTarArchiveEntry(TarArchiveEntry entry) {
archiveMap.put(
entry, entry.isFile() ? Blobs.from(entry.getPath()) : Blobs.from(ignored -> {}, true));
}
/**
* Adds... | @@ -77,7 +78,7 @@ public void addByteEntry(byte[] contents, String name, Instant modificationTime)
TarArchiveEntry entry = new TarArchiveEntry(name);
entry.setSize(contents.length);
entry.setModTime(modificationTime.toEpochMilli());
- archiveMap.put(entry, Blobs.from(outputStream -> outputStream.write... | jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java | 26 | Java | 0.786 | suggestion | 249 | 45 | 45 | false | Retry network operations with registries on I/O errors | 3,351 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | rmannibucau | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java
PR Title: Retry network operations with registries on I/O errors
BEFORE CODE: }
}
/**
* Adds a {@link TarArchiveEntry} to the archive.
*
* @param entry the {@link TarAr... | I think true. (`contents` isn't totally immutable as it's a reference to an array, but this is implied and assumed in the existing code.)
```suggestion
archiveMap.put(entry, Blobs.from(outputStream -> outputStream.write(contents), true));
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
/*
* Copyright 2019 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | Love the refactoring changes here. | /*
* Copyright 2019 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | @@ -16,12 +16,13 @@
package com.google.cloud.tools.jib.api;
+import static com.google.common.truth.Truth.assertThat; | jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ReproducibleImageTest.java | 19 | Java | 0.143 | refactor | 34 | 44 | 44 | false | Reset user and group for automatically added parent directories while building reproducible layer tars | 3,353 | GoogleContainerTools/jib | 11,032 | Java | mpeddada1 | chanseokoh | Review this pull request change.
Language: Java
File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ReproducibleImageTest.java
PR Title: Reset user and group for automatically added parent directories while building reproducible layer tars
BEFORE CODE: /*
* Copyright 2019 Google LLC.
*
* Lice... | Love the refactoring changes here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
private static final Path DIRECTORY_FILE = Paths.get(".");
private final List<TarArchiveEntry> entries = new ArrayList<>();
private final Set<String> names = new HashSet<>();
/**
* Adds a {@link TarArchiveEntry} if its extraction path does not exist yet. Also adds all of
* the parent directo... | Just make this method `throws IOException`. I've verified that this is the simplest (and also right) change. |
private final List<TarArchiveEntry> entries = new ArrayList<>();
private final Set<String> names = new HashSet<>();
/**
* Adds a {@link TarArchiveEntry} if its extraction path does not exist yet. Also adds all of
* the parent directories on the extraction path, if the parent does not exist. Pare... | @@ -72,7 +74,12 @@ private void add(TarArchiveEntry tarArchiveEntry) {
// directories.
Path namePath = Paths.get(tarArchiveEntry.getName());
if (namePath.getParent() != namePath.getRoot()) {
- TarArchiveEntry dir = new TarArchiveEntry(DIRECTORY_FILE, namePath.getParent().toString());
+ ... | jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java | 26 | Java | 0.714 | suggestion | 108 | 51 | 51 | false | Allow jib images to be built from TarArchiveEntries on alternative FileSystems | 3,357 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | Sineaggi | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java
PR Title: Allow jib images to be built from TarArchiveEntries on alternative FileSystems
BEFORE CODE: private static final Path DIRECTORY_FILE = Paths.get(".");
privat... | Just make this method `throws IOException`. I've verified that this is the simplest (and also right) change. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
private final ImmutableList<FileEntry> layerEntries;
public ReproducibleLayerBuilder(ImmutableList<FileEntry> layerEntries) {
this.layerEntries = layerEntries;
}
/**
* Builds and returns the layer {@link Blob}.
*
* @return the new layer
*/
public Blob build() {
UniqueTarArchiveEntri... | Likewise, have `build() throws IOException`. All will be fine; no more propagated changes beyond this point. | this.layerEntries = layerEntries;
}
/**
* Builds and returns the layer {@link Blob}.
*
* @return the new layer
* @throws IOException if an I/O error occurs
*/
public Blob build() throws IOException {
UniqueTarArchiveEntries uniqueTarArchiveEntries = new UniqueTarArchiveEntries();
// A... | @@ -145,9 +152,13 @@ public Blob build() {
for (FileEntry layerEntry : layerEntries) {
// Adds the entries to uniqueTarArchiveEntries, which makes sure all entries are unique and
// adds parent directories for each extraction path.
- TarArchiveEntry entry =
- new TarArchiveEntry(
- ... | jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java | 26 | Java | 0.714 | suggestion | 108 | 51 | 47 | false | Allow jib images to be built from TarArchiveEntries on alternative FileSystems | 3,357 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | Sineaggi | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java
PR Title: Allow jib images to be built from TarArchiveEntries on alternative FileSystems
BEFORE CODE: }
private final ImmutableList<FileEntry> layerEntries;
public Repr... | Likewise, have `build() throws IOException`. All will be fine; no more propagated changes beyond this point. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
* name) from name-sorted tar archive entries.
*/
public class ReproducibleLayerBuilder {
/**
* Holds a list of {@link TarArchiveEntry}s with unique extraction paths. The list also includes
* all parent directories for each extraction path.
*/
private static class UniqueTarArchiveEntries {
/**
... | Huh, doesn't it complain that you don't have `@throw` here? (Maybe because it's not a public method.) | * name) from name-sorted tar archive entries.
*/
public class ReproducibleLayerBuilder {
/**
* Holds a list of {@link TarArchiveEntry}s with unique extraction paths. The list also includes
* all parent directories for each extraction path.
*/
private static class UniqueTarArchiveEntries {
/**
... | @@ -63,7 +64,7 @@
*
* @param tarArchiveEntry the {@link TarArchiveEntry} | jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java | 26 | Java | 0.571 | suggestion | 101 | 51 | 51 | false | Allow jib images to be built from TarArchiveEntries on alternative FileSystems | 3,357 | GoogleContainerTools/jib | 11,032 | Java | chanseokoh | Sineaggi | Review this pull request change.
Language: Java
File: jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java
PR Title: Allow jib images to be built from TarArchiveEntries on alternative FileSystems
BEFORE CODE: * name) from name-sorted tar archive entries.
*/
public class Reproducib... | Huh, doesn't it complain that you don't have `@throw` here? (Maybe because it's not a public method.) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.