Skip to content

[ARIES-1992] Fix loss of PU override properties #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class AriesEntityManagerFactoryBuilder implements EntityManagerFactoryBui

private boolean complete;

private Map<String, Object> overrides;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i get it right this is normally set only once at a time (when the config changes), so maybe make it an AtomicReference ?



public AriesEntityManagerFactoryBuilder(BundleContext containerContext, PersistenceProvider provider, Bundle providerBundle, PersistenceUnit persistenceUnit) {
Expand Down Expand Up @@ -210,7 +211,11 @@ private Map<String, Object> processProperties(Map<String, Object> props) {
for(String key : punitProps.stringPropertyNames()) {
processed.put(key, punitProps.get(key));
}

synchronized (this) {
if (overrides != null) {
processed.putAll(overrides);
}
}
if(props != null) {
processed.putAll(props);
}
Expand Down Expand Up @@ -537,4 +542,8 @@ private void dataSourceReady(DataSource ds, Map<String, Object> props) {
}
createEntityManagerFactory(props);
}

public synchronized void setOverrides(Map<String, Object> overrides) {
this.overrides = overrides;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void updated(Dictionary<String, ?> properties) throws ConfigurationExcept
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Using properties override {}", overrides);
}

builder.setOverrides(overrides);
builder.createEntityManagerFactory(overrides);
configured.set(true);
}
Expand Down