From eeab571a086527d2d7fba60e0c20a75b6c21f95e Mon Sep 17 00:00:00 2001 From: hujie Date: Fri, 12 Oct 2018 10:30:38 +0800 Subject: [PATCH] CI no environment 6 --- .../acl/plug/DefaultAclRemotingServiceImpl.java | 5 +---- .../acl/plug/engine/PlainAclPlugEngine.java | 2 +- .../acl/plug/engine/PlainAclPlugEngineTest.java | 17 +++++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java index 240c9a24..b42205ab 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServiceImpl.java @@ -35,10 +35,7 @@ public class DefaultAclRemotingServiceImpl implements AclRemotingService { if (authenticationResult.getException() != null) { throw new AclPlugRuntimeException(String.format("eachCheck the inspection appear exception, accessControl data is %s", accessControl.toString()), authenticationResult.getException()); } - if (authenticationResult.getAccessControl() == null) { - throw new AclPlugRuntimeException(String.format("%s accessControl data is %s", authenticationResult.getResultString(), accessControl.toString())); - } - if (!authenticationResult.isSucceed()) { + if (authenticationResult.getAccessControl() == null || !authenticationResult.isSucceed()) { throw new AclPlugRuntimeException(String.format("%s accessControl data is %s", authenticationResult.getResultString(), accessControl.toString())); } return authenticationResult; diff --git a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java index 5237d665..8cc7b366 100644 --- a/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java +++ b/acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java @@ -41,7 +41,7 @@ public class PlainAclPlugEngine extends LoginInfoAclPlugEngine { fis = new FileInputStream(new File(filePath)); transport = ymal.loadAs(fis, BorkerAccessControlTransport.class); } catch (Exception e) { - throw new AclPlugRuntimeException(String.format("The transport.yml file for Plain mode was not found , paths %s" , filePath), e); + throw new AclPlugRuntimeException(String.format("The transport.yml file for Plain mode was not found , paths %s", filePath), e); } finally { if (fis != null) { try { diff --git a/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java b/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java index 9bdde159..034d686b 100644 --- a/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java +++ b/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -60,13 +61,17 @@ public class PlainAclPlugEngineTest { String home = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV)); InputStream fis = null; if (home == null) { - home = "/home/travis/build/githublaohu/rocketmq/acl-plug/src/test/resources"; - String filePath = home + "/conf/transport.yml"; - fis = new FileInputStream(new File(filePath)); - } else { - String filePath = home + "/conf/transport.yml"; - fis = new FileInputStream(new File(filePath)); + URL url = PlainAclPlugEngineTest.class.getResource("/"); + home = url.toString(); + home = home.substring(0, home.length() - 1).replace("file:/", "").replace("target/test-classes", ""); + home = home + "src/test/resources"; + if (!new File(home + "/conf/transport.yml").exists()) { + home = "/home/travis/build/githublaohu/rocketmq/acl-plug/src/test/resources"; + } } + String filePath = home + "/conf/transport.yml"; + fis = new FileInputStream(new File(filePath)); + transport = ymal.loadAs(fis, BorkerAccessControlTransport.class); ControllerParameters controllerParametersEntity = new ControllerParameters(); -- GitLab