Skip to content

Commit

Permalink
feat(JDK): Support for Java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
hypery2k committed Feb 6, 2020
1 parent a731431 commit c0712bc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ language: java

jdk:
- oraclejdk8
- oraclejdk11
- openjdk10
- openjdk11

env:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.47</version>
<version>3.48</version>
</parent>

<properties>
<jenkins.version>2.138.1</jenkins.version>
<jenkins.version>2.164.3</jenkins.version>

<java.level>8</java.level>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.Exported;
import sun.security.validator.ValidatorException;

import javax.net.ssl.SSLHandshakeException;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -542,6 +542,7 @@ public void setBuildServerUrl(String buildServerUrl) {
public void setTrustSSL(boolean trustSSL) {
this.trustSSL = trustSSL;
}

@DataBoundSetter
public void setWebhookToken(String webhookToken) {
this.webhookToken = webhookToken;
Expand Down Expand Up @@ -626,7 +627,7 @@ public FormValidation doTestConnection(@QueryParameter("rocketServerUrl") final
return FormValidation.ok("Success");
} catch (Exception e) {
if (e.getCause() != null &&
e.getCause().getClass() == SSLHandshakeException.class || e.getCause().getClass() == ValidatorException.class) {
e.getCause().getClass() == SSLHandshakeException.class || e.getCause().getClass() == CertificateException.class) {
LOGGER.log(Level.SEVERE, "SSL error during trying to send rocket message", e);
return FormValidation.error(e, "SSL error", e);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package jenkins.plugins.rocketchatnotifier;

import jenkins.plugins.rocketchatnotifier.rocket.errorhandling.RocketClientException;
import sun.security.validator.ValidatorException;

import java.security.cert.CertificateException;
import java.util.List;
import java.util.Map;

Expand All @@ -16,5 +16,5 @@ public interface RocketClient {

boolean publish(String message, String emoji, String avatar, List<Map<String, Object>> attachments);

void validate() throws ValidatorException, RocketClientException;
void validate() throws CertificateException, RocketClientException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import jenkins.plugins.rocketchatnotifier.rocket.RocketChatClient;
import jenkins.plugins.rocketchatnotifier.rocket.RocketChatClientImpl;
import jenkins.plugins.rocketchatnotifier.rocket.errorhandling.RocketClientException;
import sun.security.validator.ValidatorException;

import java.security.cert.CertificateException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
Expand Down Expand Up @@ -36,12 +36,10 @@ public boolean publish(String message, List<Map<String, Object>> attachments) {
LOGGER.fine("Starting sending message to channel " + this.channel);
this.client.send(this.channel, message, null, null, attachments);
return true;
}
catch (RocketClientException e) {
} catch (RocketClientException e) {
LOGGER.log(Level.SEVERE, "I/O error error during publishing message", e);
return false;
}
catch (Exception e) {
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Unknown error error during publishing message", e);
return false;
}
Expand All @@ -53,19 +51,17 @@ public boolean publish(final String message, final String emoji, final String av
LOGGER.fine("Starting sending message to channel " + this.channel);
this.client.send(this.channel, message, emoji, avatar, attachments);
return true;
}
catch (RocketClientException e) {
} catch (RocketClientException e) {
LOGGER.log(Level.SEVERE, "I/O error error during publishing message", e);
return false;
}
catch (Exception e) {
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Unknown error error during publishing message", e);
return false;
}
}

@Override
public void validate() throws ValidatorException, RocketClientException {
public void validate() throws CertificateException, RocketClientException {
LOGGER.fine("Starting validating");
this.client.getChannels();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import jenkins.plugins.rocketchatnotifier.rocket.errorhandling.RocketClientException;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
import sun.security.validator.ValidatorException;

import java.security.cert.CertificateException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -62,7 +62,7 @@ public boolean publish(final String message, final String emoji, final String av
}

@Override
public void validate() throws ValidatorException, RocketClientException {
public void validate() throws CertificateException, RocketClientException {
this.client.send("", "Test message from Jenkins via Webhook");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package jenkins.plugins.rocketchatnotifier.rocket;

import jenkins.plugins.rocketchatnotifier.model.Info;
import jenkins.plugins.rocketchatnotifier.model.Room;
import jenkins.plugins.rocketchatnotifier.model.User;
import jenkins.plugins.rocketchatnotifier.rocket.errorhandling.RocketClientException;
import sun.security.validator.ValidatorException;

import java.security.cert.CertificateException;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -46,20 +45,20 @@ public interface RocketChatClient {
*
* @param room to use (aka channel)
* @param message to send
* @throws ValidatorException in case of SSL errors
* @throws CertificateException in case of SSL errors
* @throws RocketClientException in case of communication errors with the RocketChat server backend
*/
void send(Room room, String message) throws ValidatorException, RocketClientException;
void send(Room room, String message) throws CertificateException, RocketClientException;

/**
* sends a message to a channel
*
* @param channelName to use
* @param message to send
* @throws ValidatorException in case of SSL errors
* @throws CertificateException in case of SSL errors
* @throws RocketClientException in case of communication errors with the RocketChat server backend
*/
void send(String channelName, String message) throws ValidatorException, RocketClientException;
void send(String channelName, String message) throws CertificateException, RocketClientException;

/**
* sends a message to a channel.
Expand All @@ -69,10 +68,10 @@ public interface RocketChatClient {
* @param message to send
* @param emoji to display
* @param avatar to display
* @throws ValidatorException in case of SSL errors
* @throws CertificateException in case of SSL errors
* @throws RocketClientException in case of communication errors with the RocketChat server backend
*/
void send(String channelName, String message, String emoji, String avatar) throws ValidatorException, RocketClientException;
void send(String channelName, String message, String emoji, String avatar) throws CertificateException, RocketClientException;

/**
* sends a message to a channel.
Expand All @@ -83,11 +82,11 @@ public interface RocketChatClient {
* @param emoji to display
* @param avatar to display
* @param attachments to send
* @throws ValidatorException in case of SSL errors
* @throws CertificateException in case of SSL errors
* @throws RocketClientException in case of communication errors with the RocketChat server backend
*/
void send(String channelName, String message, String emoji, String avatar, List<Map<String, Object>> attachments)
throws ValidatorException, RocketClientException;
throws CertificateException, RocketClientException;

/**
* Retrieves server information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import jenkins.plugins.rocketchatnotifier.RocketClientImpl;
import jenkins.plugins.rocketchatnotifier.model.Info;
import jenkins.plugins.rocketchatnotifier.model.Response;
import jenkins.plugins.rocketchatnotifier.model.Room;
import jenkins.plugins.rocketchatnotifier.model.User;
import jenkins.plugins.rocketchatnotifier.rocket.errorhandling.RocketClientException;
import org.apache.commons.lang.StringUtils;
import org.json.simple.JSONValue;
import sun.security.validator.ValidatorException;

import java.io.IOException;
import java.security.cert.CertificateException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -127,24 +126,24 @@ public String getInfo() throws RocketClientException {
}

@Override
public void send(Room room, String message) throws ValidatorException, RocketClientException {
public void send(Room room, String message) throws CertificateException, RocketClientException {
this.send(room.getName(), message);
}

@Override
public void send(String channelName, String message) throws ValidatorException, RocketClientException {
public void send(String channelName, String message) throws CertificateException, RocketClientException {
this.send(channelName, message, null, null);
}

@Override
public void send(final String channelName, final String message, final String emoji, final String avatar)
throws ValidatorException, RocketClientException {
throws CertificateException, RocketClientException {
this.send(channelName, message, emoji, avatar, null);
}

@Override
public void send(final String channelName, final String message, final String emoji, final String avatar, final List<Map<String, Object>> attachments)
throws ValidatorException, RocketClientException {
throws CertificateException, RocketClientException {
if (!channelName.contains(",")) {
sendSingleMessage(channelName, message, emoji, avatar, attachments);
return;
Expand Down

0 comments on commit c0712bc

Please sign in to comment.