Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions sdk-platform-java/gapic-generator-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,7 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -62,7 +61,7 @@ public abstract static class Builder {

public abstract Builder setIsSampleCode(boolean isSampleCode);

public Builder addCatch(@Nonnull VariableExpr variableExpr, List<Statement> body) {
public Builder addCatch(VariableExpr variableExpr, List<Statement> body) {
List<VariableExpr> catchVarExprs = new ArrayList<>(catchVariableExprs());
catchVarExprs.add(variableExpr);
setCatchVariableExprs(catchVarExprs);
Comment on lines +64 to 67

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The body parameter in addCatch is currently unused, which means the catch block's statements are ignored and not added to the TryCatchStatement. If TryCatchStatement uses catchBlocks() to store the catch block bodies, you should update this method to also add the body to catchBlocks().

Suggested change
public Builder addCatch(VariableExpr variableExpr, List<Statement> body) {
List<VariableExpr> catchVarExprs = new ArrayList<>(catchVariableExprs());
catchVarExprs.add(variableExpr);
setCatchVariableExprs(catchVarExprs);
public Builder addCatch(VariableExpr variableExpr, List<Statement> body) {
List<VariableExpr> catchVarExprs = new ArrayList<>(catchVariableExprs());
catchVarExprs.add(variableExpr);
setCatchVariableExprs(catchVarExprs);
List<List<Statement>> catchBodies = new ArrayList<>(catchBlocks());
catchBodies.add(body);
setCatchBlocks(catchBodies);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand All @@ -93,12 +92,12 @@ public void clear() {
importShortNames.clear();
}

public void initialize(@Nonnull String currentPackage) {
public void initialize(String currentPackage) {
this.currentPackage = currentPackage;
currentClassName = null;
}

public void initialize(@Nonnull String currentPackage, @Nonnull String currentClassName) {
public void initialize(String currentPackage, String currentClassName) {
this.currentPackage = currentPackage;
this.currentClassName = currentClassName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.api.generator.gapic.model;

import com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;

/**
Expand All @@ -24,13 +23,13 @@
*/
@NullMarked
public class SourceCodeInfoLocation {
@Nonnull private final Location location;
private final Location location;

private SourceCodeInfoLocation(Location location) {
this.location = location;
}

public static SourceCodeInfoLocation create(@Nonnull Location location) {
public static SourceCodeInfoLocation create(Location location) {
return new SourceCodeInfoLocation(location);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;

@NullMarked
Expand Down Expand Up @@ -64,7 +63,7 @@ public class TypeParser {
.put(JavaType.BYTE_STRING, REFERENCE_BYTE_STRING)
.build();

public static TypeNode parseType(@Nonnull FieldDescriptor field) {
public static TypeNode parseType(FieldDescriptor field) {
if (field.isMapField()) {
return createMapType(field);
}
Expand All @@ -85,11 +84,11 @@ public static TypeNode parseType(@Nonnull FieldDescriptor field) {
return TypeNode.withReference(parseFieldReference(field));
}

public static TypeNode parseType(@Nonnull Descriptor messageDescriptor) {
public static TypeNode parseType(Descriptor messageDescriptor) {
return TypeNode.withReference(parseMessageReference(messageDescriptor));
}

public static TypeNode parseType(@Nonnull EnumDescriptor enumDescriptor) {
public static TypeNode parseType(EnumDescriptor enumDescriptor) {
return TypeNode.withReference(parseEnumReference(enumDescriptor));
}

Expand Down Expand Up @@ -121,7 +120,7 @@ static Reference parseFieldReference(FieldDescriptor field) {
}

@VisibleForTesting
static Reference parseMessageReference(@Nonnull Descriptor messageDescriptor) {
static Reference parseMessageReference(Descriptor messageDescriptor) {
List<String> outerNestedTypeNames = new ArrayList<>();
FileOptions fileOptions = messageDescriptor.getFile().getOptions();
String javaOuterClassname =
Expand Down Expand Up @@ -181,7 +180,7 @@ static Reference parseMessageReference(@Nonnull Descriptor messageDescriptor) {
}

@VisibleForTesting
static Reference parseEnumReference(@Nonnull EnumDescriptor enumDescriptor) {
static Reference parseEnumReference(EnumDescriptor enumDescriptor) {
// This is similar to parseMessageReference, but we make it a separate method because
// EnumDescriptor and Descriptor are sibling types.
FileOptions fileOptions = enumDescriptor.getFile().getOptions();
Expand Down
Loading