Merge branch 'stable-3.1'

* stable-3.1:
  Bump Bazel version to 3.4.1

Change-Id: I75855ea41b741260db37120a93ee0c2a6d9b144a
diff --git a/WORKSPACE b/WORKSPACE
index 8b957e6..548beee 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "b6cb89690a5e06261932eb30c95fd8db34a7943a",
+    commit = "74f9d8e76d5014d218ae6fe55127a5288c9a32c3",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/src/main/java/com/ericsson/gerrit/plugins/goimport/GoImportFilter.java b/src/main/java/com/ericsson/gerrit/plugins/goimport/GoImportFilter.java
index 6a3b9a3..f59c9c1 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/goimport/GoImportFilter.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/goimport/GoImportFilter.java
@@ -37,6 +37,7 @@
 import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Optional;
 import java.util.regex.Pattern;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
@@ -192,7 +193,7 @@
   }
 
   private boolean projectExists(String projectName) {
-    ProjectState p = projectCache.get(Project.nameKey(projectName));
-    return p != null;
+    Optional<ProjectState> p = projectCache.get(Project.nameKey(projectName));
+    return p.isPresent();
   }
 }
diff --git a/src/test/java/com/ericsson/gerrit/plugins/goimport/GoImportFilterTest.java b/src/test/java/com/ericsson/gerrit/plugins/goimport/GoImportFilterTest.java
index 4bc2978..89d1ee5 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/goimport/GoImportFilterTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/goimport/GoImportFilterTest.java
@@ -33,6 +33,7 @@
 import com.google.inject.Provider;
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.Optional;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
@@ -90,7 +91,6 @@
     unitUnderTest = new GoImportFilter(mockAnonProvider, mockPerms, mockProjectCache, PROD_URL);
     assertThat(unitUnderTest).isNotNull();
     when(mockResponse.getOutputStream()).thenReturn(mockOutputStream);
-
     when(mockAnonProvider.get()).thenReturn(mockAnon);
     when(mockPerms.user(mockAnon)).thenReturn(mockPermsWithUser);
     when(mockPermsWithUser.ref(any())).thenReturn(mockPermsForRef);
@@ -140,7 +140,8 @@
   public void testDoFilterWithExistingProject() throws Exception {
     when(mockRequest.getServletPath()).thenReturn("/" + PROJECT_NAME);
     when(mockRequest.getParameter("go-get")).thenReturn("1");
-    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME))).thenReturn(mockProjectState);
+    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME)))
+        .thenReturn(Optional.of(mockProjectState));
     when(mockPermsForRef.testOrFalse(RefPermission.READ)).thenReturn(false);
     unitUnderTest.doFilter(mockRequest, mockResponse, mockChain);
     verify(mockOutputStream, times(1)).write(response200(false, false));
@@ -154,7 +155,8 @@
   public void testDoFilterAuthenticatedWithExistingProject() throws Exception {
     when(mockRequest.getServletPath()).thenReturn("/a/" + PROJECT_NAME);
     when(mockRequest.getParameter("go-get")).thenReturn("1");
-    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME))).thenReturn(mockProjectState);
+    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME)))
+        .thenReturn(Optional.of(mockProjectState));
     when(mockPermsForRef.testOrFalse(RefPermission.READ)).thenReturn(false);
     unitUnderTest.doFilter(mockRequest, mockResponse, mockChain);
     verify(mockOutputStream, times(1)).write(response200(false, true));
@@ -168,7 +170,8 @@
   public void testDoFilterWithExistingProjectAndPackage() throws Exception {
     when(mockRequest.getServletPath()).thenReturn("/" + PROJECT_NAME + "/my/package");
     when(mockRequest.getParameter("go-get")).thenReturn("1");
-    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME))).thenReturn(mockProjectState);
+    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME)))
+        .thenReturn(Optional.of(mockProjectState));
     when(mockPermsForRef.testOrFalse(RefPermission.READ)).thenReturn(false);
     unitUnderTest.doFilter(mockRequest, mockResponse, mockChain);
     verify(mockOutputStream, times(1)).write(response200(false, false));
@@ -181,7 +184,8 @@
   public void testDoFilterWithAnonymousAccessibleProject() throws Exception {
     when(mockRequest.getServletPath()).thenReturn("/projectName");
     when(mockRequest.getParameter("go-get")).thenReturn("1");
-    when(mockProjectCache.get(Project.nameKey("projectName"))).thenReturn(mockProjectState);
+    when(mockProjectCache.get(Project.nameKey(PROJECT_NAME)))
+        .thenReturn(Optional.of(mockProjectState));
     when(mockPermsForRef.testOrFalse(RefPermission.READ)).thenReturn(true);
     unitUnderTest.doFilter(mockRequest, mockResponse, mockChain);
     verify(mockOutputStream, times(1)).write(response200(true, false));
@@ -195,7 +199,7 @@
   public void testDoFilterWithNonExistingProject() throws Exception {
     when(mockRequest.getServletPath()).thenReturn("/" + PROJECT_NAME);
     when(mockRequest.getParameter("go-get")).thenReturn("1");
-    when(mockProjectCache.get(any(Project.NameKey.class))).thenReturn(null);
+    when(mockProjectCache.get(any(Project.NameKey.class))).thenReturn(Optional.empty());
     unitUnderTest.doFilter(mockRequest, mockResponse, mockChain);
     verify(mockOutputStream, times(1)).write(any(byte[].class));
     verify(mockChain, times(0)).doFilter(mockRequest, mockResponse);
@@ -209,7 +213,8 @@
     when(mockRequest.getServletPath()).thenReturn("/" + PROJECT_NAME);
     when(mockRequest.getParameter("go-get")).thenReturn("1");
     doThrow(new IOException(msg)).when(mockOutputStream).write(any(byte[].class));
-    when(mockProjectCache.get(any(Project.NameKey.class))).thenReturn(mockProjectState);
+    when(mockProjectCache.get(any(Project.NameKey.class)))
+        .thenReturn(Optional.of(mockProjectState));
     IOException thrown =
         assertThrows(
             IOException.class, () -> unitUnderTest.doFilter(mockRequest, mockResponse, mockChain));