Commit 6e6799dd by Johannes Edmeier

Fix some codacy issues

parent f5cb00b7
......@@ -43,7 +43,7 @@ module.exports = function ($rootScope, jolokia, $q) {
var name = '';
var type = '';
var parts = rBeanName.split(',');
for (var i in parts) {
for (var i = 0; i < parts.length; i++) {
var tokens = parts[i].split('=');
if (tokens[0].toLowerCase() === 'name') {
name = tokens[1];
......
......@@ -112,7 +112,7 @@ public class RevereseZuulProxyConfiguration extends ZuulConfiguration {
private static class ZuulRefreshListener implements ApplicationListener<ApplicationEvent> {
private ZuulHandlerMapping zuulHandlerMapping;
public ZuulRefreshListener(ZuulHandlerMapping zuulHandlerMapping) {
private ZuulRefreshListener(ZuulHandlerMapping zuulHandlerMapping) {
this.zuulHandlerMapping = zuulHandlerMapping;
}
......
......@@ -30,7 +30,7 @@ import de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent;
* @author Johannes Edmeier
*/
public class RemindingNotifier implements Notifier {
private final ConcurrentHashMap<String, Reminder> reminders = new ConcurrentHashMap<String, Reminder>();
private final ConcurrentHashMap<String, Reminder> reminders = new ConcurrentHashMap<>();
private long reminderPeriod = TimeUnit.MINUTES.toMillis(10L);
private String[] reminderStatuses = { "DOWN", "OFFLINE" };
private final Notifier delegate;
......@@ -51,7 +51,7 @@ public class RemindingNotifier implements Notifier {
public void sendReminders() {
long now = System.currentTimeMillis();
for (Reminder reminder : new ArrayList<Reminder>(reminders.values())) {
for (Reminder reminder : new ArrayList<>(reminders.values())) {
if (now - reminder.getLastNotification() > reminderPeriod) {
reminder.setLastNotification(now);
delegate.notify(reminder.getEvent());
......@@ -92,7 +92,7 @@ public class RemindingNotifier implements Notifier {
private final ClientApplicationEvent event;
private long lastNotification;
public Reminder(ClientApplicationEvent event) {
private Reminder(ClientApplicationEvent event) {
this.event = event;
this.lastNotification = event.getTimestamp();
}
......
......@@ -43,7 +43,7 @@ public class ConcatenatingResourceResolver extends AbstractResourceResolver {
private final byte[] delimiter;
public ConcatenatingResourceResolver(byte[] delimiter) {
this.delimiter = delimiter;
this.delimiter = delimiter.clone();
}
@Override
......
......@@ -154,10 +154,8 @@ public class ApplicationRouteLocator implements RefreshableRouteLocator {
private String stripServletPath(final String path) {
String adjustedPath = path;
if (StringUtils.hasText(servletPath)) {
if (!servletPath.equals("/")) {
if (StringUtils.hasText(servletPath) && !"/".equals(servletPath)) {
adjustedPath = path.substring(this.servletPath.length());
}
}
LOGGER.debug("adjustedPath={}", path);
......
......@@ -97,7 +97,7 @@ public class MailNotifierTest {
Notifier notifier = new AbstractStatusChangeNotifier() {
@Override
protected void doNotify(ClientApplicationStatusChangedEvent event) throws Exception {
throw new RuntimeException();
throw new IllegalStateException("test");
}
};
notifier.notify(new ClientApplicationStatusChangedEvent(
......
......@@ -6,7 +6,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.junit.After;
import org.junit.Test;
......@@ -30,7 +29,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void test_mgmtPortPath() {
public void test_mgmtPortPath() throws Exception {
load("management.contextPath=/admin", "endpoints.health.id=alive", "local.server.port=8080",
"local.management.port=8081");
AdminClientProperties clientProperties = new AdminClientProperties();
......@@ -46,7 +45,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void test_contextPath_mgmtPath() {
public void test_contextPath_mgmtPath() throws Exception {
load("server.context-path=app", "management.context-path=/admin", "local.server.port=8080");
AdminClientProperties clientProperties = new AdminClientProperties();
context.getAutowireCapableBeanFactory().autowireBean(clientProperties);
......@@ -61,7 +60,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void test_contextPatht_mgmtPortPath() {
public void test_contextPatht_mgmtPortPath() throws Exception {
load("server.context-path=app", "management.context-path=/admin", "local.server.port=8080",
"local.management.port=8081");
AdminClientProperties clientProperties = new AdminClientProperties();
......@@ -77,7 +76,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void test_contextPath() {
public void test_contextPath() throws Exception {
load("server.context-path=app", "local.server.port=80");
AdminClientProperties clientProperties = new AdminClientProperties();
context.getAutowireCapableBeanFactory().autowireBean(clientProperties);
......@@ -91,7 +90,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void test_servletPath() {
public void test_servletPath() throws Exception {
load("server.servlet-path=app", "server.context-path=srv", "local.server.port=80");
AdminClientProperties clientProperties = new AdminClientProperties();
context.getAutowireCapableBeanFactory().autowireBean(clientProperties);
......@@ -106,7 +105,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void test_default() {
public void test_default() throws Exception {
load("local.server.port=8080");
AdminClientProperties clientProperties = new AdminClientProperties();
context.getAutowireCapableBeanFactory().autowireBean(clientProperties);
......@@ -119,7 +118,7 @@ public class AdminClientPropertiesTest {
}
@Test
public void testSsl() {
public void testSsl() throws Exception {
load("server.ssl.key-store=somefile.jks", "server.ssl.key-store-password=password",
"local.server.port=8080");
AdminClientProperties clientProperties = new AdminClientProperties();
......@@ -173,12 +172,8 @@ public class AdminClientPropertiesTest {
assertThat(clientProperties.getServiceUrl(), is("http://127.0.0.1:8080"));
}
private String getHostname() {
try {
private String getHostname() throws Exception {
return InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
private void publishApplicationReadyEvent(AdminClientProperties client) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment