Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 927b4d0

Browse files
author
Adam Lindenthal
committed
Prevent double registering components when injecting managed client
Change-Id: I4f1c3e6642800cff4e47b1e81f0a49b9bbd07c84
1 parent 7ce786f commit 927b4d0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core-common/src/main/java/org/glassfish/jersey/model/internal/ComponentBag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2016 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -400,7 +400,7 @@ private boolean registerModel(final Class<?> componentClass,
400400
public Boolean call() {
401401
if (models.containsKey(componentClass)) {
402402
Errors.error(LocalizationMessages.COMPONENT_TYPE_ALREADY_REGISTERED(componentClass),
403-
Severity.WARNING);
403+
Severity.HINT);
404404
return false;
405405
}
406406

core-server/src/main/java/org/glassfish/jersey/server/internal/inject/WebTargetValueFactoryProvider.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2016 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -319,13 +319,18 @@ public ManagedClient get() {
319319
}
320320

321321
private void copyProviders(Configuration source, Configurable<?> target) {
322+
final Configuration targetConfig = target.getConfiguration();
322323
for (Class<?> c : source.getClasses()) {
323-
target.register(c, source.getContracts(c));
324+
if (!targetConfig.isRegistered(c)) {
325+
target.register(c, source.getContracts(c));
326+
}
324327
}
325328

326329
for (Object o : source.getInstances()) {
327330
Class<?> c = o.getClass();
328-
target.register(c, source.getContracts(c));
331+
if (!targetConfig.isRegistered(o)) {
332+
target.register(c, source.getContracts(c));
333+
}
329334
}
330335
}
331336

0 commit comments

Comments
 (0)