Skip to content

Commit

Permalink
Fix build after refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
7FM committed Nov 21, 2019
1 parent 830a380 commit e5c0c15
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 57 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/jenkinsci/plugin/gitea/GiteaNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListene
SCMRevisionState pollingBaseline) throws Exception {
try {
sendNotifications(build, listener);
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
e.printStackTrace(listener.error("Could not send notifications"));
}
}
Expand All @@ -295,7 +295,7 @@ public static class JobCompletedListener extends RunListener<Run<?, ?>> {
public void onCompleted(Run<?, ?> build, TaskListener listener) {
try {
sendNotifications(build, listener);
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
e.printStackTrace(listener.error("Could not send notifications"));
}
}
Expand All @@ -307,7 +307,7 @@ public void onCompleted(Run<?, ?> build, TaskListener listener) {
public void onStarted(Run<?, ?> run, TaskListener listener) {
try {
sendNotifications(run, listener);
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
e.printStackTrace(listener.error("Could not send notifications"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,8 @@ public SCMFileSystem build(@NonNull SCMSource source, @NonNull SCMHead head, @Ch
.open();
try {
return new GiteaSCMFileSystem(connection, connection.fetchRepository(repoOwner, repository), ref, rev);
} catch (IOException | InterruptedException e) {
try {
connection.close();
} catch (IOException ioe) {
e.addSuppressed(ioe);
}
} catch (IOException e) {
connection.close();
throw e;
}
}
Expand Down
76 changes: 35 additions & 41 deletions src/main/java/org/jenkinsci/plugin/gitea/GiteaSCMSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,53 +507,47 @@ protected List<Action> retrieveActions(@NonNull SCMRevision revision, SCMHeadEve
@NonNull
@Override
protected SCMProbe createProbe(@NonNull final SCMHead head, SCMRevision revision) throws IOException {
try {
GiteaSCMFileSystem.BuilderImpl builder =
ExtensionList.lookup(SCMFileSystem.Builder.class).get(GiteaSCMFileSystem.BuilderImpl.class);
if (builder == null) {
throw new AssertionError();
}
final SCMFileSystem fs = builder.build(this, head, revision);
return new SCMProbe() {
@NonNull
@Override
public SCMProbeStat stat(@NonNull String path) throws IOException {
try {
return SCMProbeStat.fromType(fs.child(path).getType());
} catch (InterruptedException e) {
throw new IOException("Interrupted", e);
}
GiteaSCMFileSystem.BuilderImpl builder =
ExtensionList.lookup(SCMFileSystem.Builder.class).get(GiteaSCMFileSystem.BuilderImpl.class);
if (builder == null) {
throw new AssertionError();
}
final SCMFileSystem fs = builder.build(this, head, revision);
return new SCMProbe() {
@NonNull
@Override
public SCMProbeStat stat(@NonNull String path) throws IOException {
try {
return SCMProbeStat.fromType(fs.child(path).getType());
} catch (InterruptedException e) {
throw new IOException("Interrupted", e);
}
}

@Override
public void close() throws IOException {
fs.close();
}
@Override
public void close() throws IOException {
fs.close();
}

@Override
public String name() {
return head.getName();
}
@Override
public String name() {
return head.getName();
}

@Override
public long lastModified() {
try {
return fs.lastModified();
} catch (IOException e) {
return 0L;
} catch (InterruptedException e) {
return 0L;
}
@Override
public long lastModified() {
try {
return fs.lastModified();
} catch (IOException | InterruptedException e) {
return 0L;
}
}

@Override
public SCMFile getRoot() {
return fs.getRoot();
}
};
} catch (InterruptedException e) {
throw new IOException(e);
}
@Override
public SCMFile getRoot() {
return fs.getRoot();
}
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static void register(SCMNavigatorOwner owner, GiteaSCMNavigator navigator
hook.setActive(true);
c.createHook(org, hook);
}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
LOGGER.log(Level.WARNING,
"Could not manage organization hooks for " + navigator.getRepoOwner() + " on " + serverUrl, e);
}
Expand Down Expand Up @@ -221,7 +221,7 @@ public static void register(SCMSourceOwner owner, GiteaSCMSource source,
hook.setActive(true);
c.createHook(repo, hook);
}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
LOGGER.log(Level.WARNING,
"Could not manage repository hooks for " + source.getRepoOwner() + "/" + source.getRepository()
+ " on " + serverUrl, e);
Expand Down Expand Up @@ -338,7 +338,7 @@ public static void register(SCMTriggerItem item, GitSCM scm) {
hook.setActive(true);
c.createHook(repo, hook);
}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
LOGGER.log(Level.WARNING,
"Could not manage repository hooks for " + repoOwner + "/" + repoName
+ " on " + server.getServerUrl(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ public static FormValidation doCheckServerUrl(@QueryParameter String value) {
.okWithMarkup(Messages.GiteaServer_serverVersion(Util.escape(c.fetchVersion().getVersion())));
} catch (MalformedURLException e) {
return FormValidation.errorWithMarkup(Messages.GiteaServer_invalidUrl(Util.escape(e.getMessage())));
} catch (InterruptedException e) {
return FormValidation.warning(Messages.GiteaServer_versionInterrupted());
} catch (IOException e) {
return FormValidation
.errorWithMarkup(Messages.GiteaServer_cannotConnect(Util.escape(e.getMessage())));
Expand Down Expand Up @@ -323,8 +321,6 @@ public FormValidation doCheckCredentialsId(@QueryParameter String serverUrl, @Qu
return FormValidation.okWithMarkup(
Messages.GiteaServer_hookManagementAs(Util.escape(user.getUsername()))
);
} catch (InterruptedException e) {
return FormValidation.warning(Messages.GiteaServer_validateInterrupted());
} catch (IOException e) {
return FormValidation.errorWithMarkup(Messages.GiteaServer_cannotConnect(Util.escape(e.getMessage())));
}
Expand Down

0 comments on commit e5c0c15

Please sign in to comment.