Source:
<code>static AppInstallationToken generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl, String owner) { JenkinsJVM.checkJenkinsJVM(); try (Timeout timeout = Timeout.limit(30, TimeUnit.SECONDS)) { String jwtToken = createJWT(appId, appPrivateKey); GitHub gitHubApp = Connector .createGitHubBuilder(apiUrl) .withJwtToken(jwtToken) .build(); GHApp app; try { app = gitHubApp.getApp(); } catch (IOException e) { throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); } List<GHAppInstallation> appInstallations = app.listInstallations().asList(); if (appInstallations.isEmpty()) { throw new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId)); } GHAppInstallation appInstallation; if (appInstallations.size() == 1) { appInstallation = appInstallations.get(0); } else { appInstallation = appInstallations.stream() .filter(installation -> installation.getAccount().getLogin().equals(owner)) .findAny() .orElseThrow(() -> new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId))); } GHAppInstallationToken appInstallationToken = appInstallation .createToken(appInstallation.getPermissions()) .create(); long expiration = getExpirationSeconds(appInstallationToken); AppInstallationToken token = new AppInstallationToken( Secret.fromString(appInstallationToken.getToken()), expiration); LOGGER.log(Level.FINER, "Generated App Installation Token for app ID {0}", appId); LOGGER.log(Level.FINEST, () -> "Generated App Installation Token at " + Instant.now().toEpochMilli()); if (AFTER_TOKEN_GENERATION_DELAY_SECONDS > 0) { long tokenDelay = Math.min(10, AFTER_TOKEN_GENERATION_DELAY_SECONDS); LOGGER.log(Level.FINER, "Waiting {0} seconds after token generation", tokenDelay); Thread.sleep(Duration.ofSeconds(tokenDelay).toMillis()); } return token; <START> } catch (Exception e) { <END> throw new IllegalArgumentException("Failed to generate GitHub App installation token for app ID " + appId , e); } }</code><technical_language>is a SpotBugs warning this line for REC_CATCH_EXCEPTION</technical_language>

Target:
static AppInstallationToken generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl, String owner) { JenkinsJVM.checkJenkinsJVM(); try (Timeout timeout = Timeout.limit(30, TimeUnit.SECONDS)) { String jwtToken = createJWT(appId, appPrivateKey); GitHub gitHubApp = Connector .createGitHubBuilder(apiUrl) .withJwtToken(jwtToken) .build(); GHApp app; try { app = gitHubApp.getApp(); } catch (IOException e) { throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); } List<GHAppInstallation> appInstallations = app.listInstallations().asList(); if (appInstallations.isEmpty()) { throw new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId)); } GHAppInstallation appInstallation; if (appInstallations.size() == 1) { appInstallation = appInstallations.get(0); } else { appInstallation = appInstallations.stream() .filter(installation -> installation.getAccount().getLogin().equals(owner)) .findAny() .orElseThrow(() -> new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId))); } GHAppInstallationToken appInstallationToken = appInstallation .createToken(appInstallation.getPermissions()) .create(); long expiration = getExpirationSeconds(appInstallationToken); AppInstallationToken token = new AppInstallationToken( Secret.fromString(appInstallationToken.getToken()), expiration); LOGGER.log(Level.FINER, "Generated App Installation Token for app ID {0}", appId); LOGGER.log(Level.FINEST, () -> "Generated App Installation Token at " + Instant.now().toEpochMilli()); if (AFTER_TOKEN_GENERATION_DELAY_SECONDS > 0) { long tokenDelay = Math.min(10, AFTER_TOKEN_GENERATION_DELAY_SECONDS); LOGGER.log(Level.FINER, "Waiting {0} seconds after token generation", tokenDelay); Thread.sleep(Duration.ofSeconds(tokenDelay).toMillis()); } return token; } catch (IOException | InterruptedException e) { throw new IllegalArgumentException("Failed to generate GitHub App installation token for app ID " + appId , e); } }