Skip to content

Commit 912d4f7

Browse files
author
Johannes Stelzer
committed
Remove conflict detection (what is it really good for?)
1 parent 8e2ce75 commit 912d4f7

File tree

7 files changed

+20
-38
lines changed

7 files changed

+20
-38
lines changed

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/controller/RegistryController.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import de.codecentric.boot.admin.model.Application;
3232
import de.codecentric.boot.admin.registry.ApplicationRegistry;
33-
import de.codecentric.boot.admin.registry.ApplicationRegistryConflictException;
3433

3534
/**
3635
* REST controller for controlling registration of managed applications.
@@ -57,12 +56,8 @@ public RegistryController(ApplicationRegistry registry) {
5756
@RequestMapping(method = RequestMethod.POST)
5857
public ResponseEntity<Application> register(@RequestBody Application app) {
5958
LOGGER.debug("Register application {}", app.toString());
60-
try {
6159
Application registeredApp = registry.register(app);
6260
return new ResponseEntity<Application>(registeredApp, HttpStatus.CREATED);
63-
} catch (ApplicationRegistryConflictException ex) {
64-
return new ResponseEntity<Application>(HttpStatus.CONFLICT);
65-
}
6661
}
6762

6863
/**

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/ApplicationIdGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface ApplicationIdGenerator {
2121

2222
/**
2323
* Generate an id based on the given Application
24-
*
24+
*
2525
* @param a the application the id is computed for.
2626
* @return the application id
2727
*/

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/ApplicationRegistry.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public Application register(Application app) {
6969
if ((app.getUrl().equals(oldApp.getUrl()) && app.getName().equals(oldApp.getName()))) {
7070
LOGGER.debug("Application {} refreshed", newApp);
7171
} else {
72-
LOGGER.warn("Application {} not registered because of conflict with {}", newApp, oldApp);
73-
throw new ApplicationRegistryConflictException(oldApp, app);
72+
LOGGER.warn("Application {} replaced by Application {}", newApp, oldApp);
7473
}
7574
}
7675
return newApp;

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/ApplicationRegistryConflictException.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/store/HazelcastApplicationStore.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package de.codecentric.boot.admin.registry.store;
217

318
import java.util.Collection;
@@ -17,7 +32,7 @@ public HazelcastApplicationStore(IMap<String, Application> store) {
1732

1833
@Override
1934
public Application save(Application app) {
20-
return store.putIfAbsent(app.getId(), app);
35+
return store.put(app.getId(), app);
2136
}
2237

2338
@Override

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/store/SimpleApplicationStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class SimpleApplicationStore implements ApplicationStore {
3131

3232
@Override
3333
public Application save(Application app) {
34-
return map.putIfAbsent(app.getId(), app);
34+
return map.put(app.getId(), app);
3535
}
3636

3737
@Override

spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/controller/RegistryControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void register_twice() {
6969
public void register_sameUrl() {
7070
controller.register(new Application("http://localhost", "FOO"));
7171
ResponseEntity<?> response = controller.register(new Application("http://localhost", "BAR"));
72-
assertEquals(HttpStatus.CONFLICT, response.getStatusCode());
72+
assertEquals(HttpStatus.CREATED, response.getStatusCode());
7373
}
7474

7575
@Test

0 commit comments

Comments
 (0)