• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • jira-plugin
    • Jenkins 2.89.2
      Jira Plugin 2.5

      The issueCache in hudson.plugins.jira.JiraSite make use of Guava cache.

      /**
       * Returns the remote issue with the given id or <code>null</code> if it wasn't found.
       */
      @CheckForNull
      public JiraIssue getIssue(final String id) throws IOException {
          try {
      
              Issue issue = issueCache.get(id, new Callable<Issue>() {
                  public Issue call() throws Exception {
                      JiraSession session = getSession();
                      Issue issue = null;
                      if (session != null) {
                          issue = session.getIssue(id);
                      }
                      return issue;
                  }
              });
      
              if (issue == null) {
                  return null;
              }
      
              return new JiraIssue(issue);
          } catch (ExecutionException e) {
              throw new IOException(e);
          }
      }
      

      As noticed in the com.google.common.cache.Cache JavaDoc,

      V get(K key, Callable<? extends V> valueLoader) throws ExecutionException;
      

      valueLoader must not return null; it may either return a non-null value or throw an exception.

      session.getIssue(id) may return null if no such issue exists, causing throwing unhandled RuntimeExcepting com.google.common.cache.CacheLoader$InvalidCacheLoadException.

      Since no such issue can be found in Jira site, we can positively cache the null issue.

      There are various reasons for the issue can NOT be found in Jira site. Let's leave it from this issue.

          [JENKINS-48716] Prevent Guava InvalidCacheLoadException

          Zhenlei Huang created issue -
          Zhenlei Huang made changes -
          Environment Original: Jenkins 2.89.2, Jira Plugin 2.5
          New: Jenkins 2.89.2
          Jira Plugin 2.5
          Zhenlei Huang made changes -
          Description New: The issueCache in hudson.plugins.jira.JiraSite make use of Guava cache.
          {code:java}
          /**
           * Returns the remote issue with the given id or <code>null</code> if it wasn't found.
           */
          @CheckForNull
          public JiraIssue getIssue(final String id) throws IOException {
              try {

                  Issue issue = issueCache.get(id, new Callable<Issue>() {
                      public Issue call() throws Exception {
                          JiraSession session = getSession();
                          Issue issue = null;
                          if (session != null) {
                              issue = session.getIssue(id);
                          }
                          return issue;
                      }
                  });

                  if (issue == null) {
                      return null;
                  }

                  return new JiraIssue(issue);
              } catch (ExecutionException e) {
                  throw new IOException(e);
              }
          }
          {code}
          As noticed in the com.google.common.cache.Cache JavaDoc,
          {code:java}
          V get(K key, Callable<? extends V> valueLoader) throws ExecutionException;
          {code}
          valueLoader *must not* return null; it may either return a non-null value or throw an exception.

          session.getIssue(id) may return null if no such issue exists, causing throwing unhandled RuntimeExcepting com.google.common.cache.CacheLoader$InvalidCacheLoadException.

          Since no such issue can be found in Jira site, we can safely cache the
          Zhenlei Huang made changes -
          Description Original: The issueCache in hudson.plugins.jira.JiraSite make use of Guava cache.
          {code:java}
          /**
           * Returns the remote issue with the given id or <code>null</code> if it wasn't found.
           */
          @CheckForNull
          public JiraIssue getIssue(final String id) throws IOException {
              try {

                  Issue issue = issueCache.get(id, new Callable<Issue>() {
                      public Issue call() throws Exception {
                          JiraSession session = getSession();
                          Issue issue = null;
                          if (session != null) {
                              issue = session.getIssue(id);
                          }
                          return issue;
                      }
                  });

                  if (issue == null) {
                      return null;
                  }

                  return new JiraIssue(issue);
              } catch (ExecutionException e) {
                  throw new IOException(e);
              }
          }
          {code}
          As noticed in the com.google.common.cache.Cache JavaDoc,
          {code:java}
          V get(K key, Callable<? extends V> valueLoader) throws ExecutionException;
          {code}
          valueLoader *must not* return null; it may either return a non-null value or throw an exception.

          session.getIssue(id) may return null if no such issue exists, causing throwing unhandled RuntimeExcepting com.google.common.cache.CacheLoader$InvalidCacheLoadException.

          Since no such issue can be found in Jira site, we can safely cache the
          New: The issueCache in hudson.plugins.jira.JiraSite make use of Guava cache.
          {code:java}
          /**
           * Returns the remote issue with the given id or <code>null</code> if it wasn't found.
           */
          @CheckForNull
          public JiraIssue getIssue(final String id) throws IOException {
              try {

                  Issue issue = issueCache.get(id, new Callable<Issue>() {
                      public Issue call() throws Exception {
                          JiraSession session = getSession();
                          Issue issue = null;
                          if (session != null) {
                              issue = session.getIssue(id);
                          }
                          return issue;
                      }
                  });

                  if (issue == null) {
                      return null;
                  }

                  return new JiraIssue(issue);
              } catch (ExecutionException e) {
                  throw new IOException(e);
              }
          }
          {code}
          As noticed in the com.google.common.cache.Cache JavaDoc,
          {code:java}
          V get(K key, Callable<? extends V> valueLoader) throws ExecutionException;
          {code}
          valueLoader *must not* return null; it may either return a non-null value or throw an exception.

          session.getIssue(id) may return null if no such issue exists, causing throwing unhandled RuntimeExcepting com.google.common.cache.CacheLoader$InvalidCacheLoadException.

          Since no such issue can be found in Jira site, we can positively cache the null issue.

          There are various reasons for the issue can NOT be found in Jira site. Let's leave it from this issue.
          Zhenlei Huang made changes -
          Link New: This issue is related to JENKINS-35998 [ JENKINS-35998 ]

          Code changed in jenkins
          User: zlei
          Path:
          src/main/java/hudson/plugins/jira/JiraSite.java
          src/test/groovy/hudson/plugins/jira/JiraSiteTest.groovy
          http://jenkins-ci.org/commit/jira-plugin/a1909b0f401e12677950c57f605f7b417c75f50f
          Log:
          JENKINS-48716 Prevent Guava InvalidCacheLoadException (#136)

          JENKINS-48716 JENKINS-35998 Prevent Guava InvalidCacheLoadException

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: zlei Path: src/main/java/hudson/plugins/jira/JiraSite.java src/test/groovy/hudson/plugins/jira/JiraSiteTest.groovy http://jenkins-ci.org/commit/jira-plugin/a1909b0f401e12677950c57f605f7b417c75f50f Log: JENKINS-48716 Prevent Guava InvalidCacheLoadException (#136) JENKINS-48716 JENKINS-35998 Prevent Guava InvalidCacheLoadException

          keir mcluskey added a comment -

          Is there a work around for this we can't get builds to pass on one of our slaves?

          keir mcluskey added a comment - Is there a work around for this we can't get builds to pass on one of our slaves?
          Zhenlei Huang made changes -
          Assignee New: Zhenlei Huang [ gmshake ]
          Zhenlei Huang made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Zhenlei Huang made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

            gmshake Zhenlei Huang
            gmshake Zhenlei Huang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: