Skip to content
Permalink
Browse files

[FIXED JENKINS-42542] SCMHeadObserver.observe(SCMHead,SCMRevision) sh…

…ould be allowed to throw IO and Interrupted exceptions
  • Loading branch information
stephenc committed Mar 7, 2017
1 parent c835fb7 commit 0204ff9994a2da87e4c9c8546060ec7aae32aa64
@@ -34,7 +34,7 @@
</parent>

<artifactId>scm-api</artifactId>
<version>2.0.9-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>SCM API Plugin</name>
@@ -30,6 +30,7 @@
import hudson.model.Item;
import hudson.scm.SCM;
import hudson.triggers.SCMTrigger;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -250,7 +251,8 @@ private Validated(O delegate, SCMSource source) {
* {@inheritDoc}
*/
@Override
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision) {
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision)
throws IOException, InterruptedException {
if (untrusted.containsKey(head)) {
trusted.put(head, revision);
untrusted.remove(head);
@@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -45,8 +46,11 @@
*
* @param head the head.
* @param revision the revision.
* @throws IOException if processing of the observation could not be completed due to an {@link IOException}.
* @throws InterruptedException if processing of the observation was interrupted
*/
public abstract void observe(@NonNull SCMHead head, @NonNull SCMRevision revision);
public abstract void observe(@NonNull SCMHead head, @NonNull SCMRevision revision)
throws IOException, InterruptedException;

/**
* Returns information about whether the observer wants more results.
@@ -197,7 +201,8 @@ public AllFinished(@NonNull Iterable<SCMHeadObserver> observers) {
* {@inheritDoc}
*/
@Override
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision) {
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision)
throws IOException, InterruptedException {
for (SCMHeadObserver observer : observers) {
if (observer.isObserving()) {
observer.observe(head, revision);
@@ -290,7 +295,8 @@ public OneFinished(@NonNull Iterable<SCMHeadObserver> observers) {
* {@inheritDoc}
*/
@Override
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision) {
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision)
throws IOException, InterruptedException {
for (SCMHeadObserver observer : observers) {
if (observer.isObserving()) {
observer.observe(head, revision);
@@ -582,7 +588,8 @@ public boolean isObserving() {
* {@inheritDoc}
*/
@Override
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision) {
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision)
throws IOException, InterruptedException {
delegate.observe(head, revision);
}

@@ -632,7 +639,8 @@ public Filter(O delegate, SCMHead... heads) {
* {@inheritDoc}
*/
@Override
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision) {
public void observe(@NonNull SCMHead head, @NonNull SCMRevision revision)
throws IOException, InterruptedException {
if (remaining.contains(head)) {
remaining.remove(head);
super.observe(head, revision);
@@ -209,7 +209,7 @@ public void originOfForwardedRequestMultiHop() throws Exception {
Mockito.when(req.getHeader("X-Forwarded-Port")).thenReturn("443");
Mockito.when(req.getHeader("X-Forwarded-For")).thenReturn("scm.example.com, gateway.example.com, proxy.example.com");
Mockito.when(req.getRequestURI()).thenReturn("/jenkins/notify");
Mockito.when(req.getLocalPort()).thenReturn(8080);
Mockito.when(req.getRemotePort()).thenReturn(8080);
Mockito.when(req.getRemoteHost()).thenReturn(null);
Mockito.when(req.getRemoteAddr()).thenReturn("203.0.113.1");
assertThat(SCMEvent.originOf(req), is("scm.example.com → gateway.example.com → proxy.example.com → 203.0.113.1 ⇒ https://jenkins.example.com/jenkins/notify"));

0 comments on commit 0204ff9

Please sign in to comment.
You can’t perform that action at this time.