Skip to content
Merged
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 @@ -52,7 +52,7 @@ class Default implements Implementation {

@Override
public <K, V> WeakMap<K, V> get() {
log.warn("WeakMap.Supplier not registered. Returning a synchronized WeakHashMap.");
log.debug("WeakMap.Supplier not registered. Returning a synchronized WeakHashMap.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we want to lower the logging level? I'd actually like to know readily if this happens.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I felt like this isn't a great reason to alert users. The main side effect would be worse performance, but that may or may not be noticeable depending on where it is applied. I can revert if you think it's important.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed that this shouldn't log to users in the default configuration. I think users should only see things that are actionable by them in the default configuration, other than version numbers

return new MapAdapter<>(Collections.synchronizedMap(new WeakHashMap<K, V>()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public static Instrumentation getInstrumentation() {
return INSTRUMENTATION;
}

static {
// WeakMap is used by other classes below, so we need to register the provider first.
AgentTooling.registerWeakMapProvider();
}

public static void installBytebuddyAgent(final Instrumentation inst) {
if (Config.get().isTraceEnabled()) {
installBytebuddyAgent(inst, false, new AgentBuilder.Listener[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AgentTooling {
registerWeakMapProvider();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this callsite still needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I left it in as a fallback... it isn't hurting anything for the time being.

}

private static void registerWeakMapProvider() {
static void registerWeakMapProvider() {
if (!WeakMap.Provider.isProviderRegistered()) {
WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent());
// WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent.Inline());
Expand Down