Skip to content
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

Fix debug logs in ConfigProxyFactory #670

Closed
wants to merge 1 commit into from
Closed
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 @@ -16,7 +16,6 @@

import javax.inject.Inject;
import java.lang.invoke.CallSite;
import java.lang.invoke.LambdaConversionException;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
Expand Down Expand Up @@ -282,7 +281,7 @@ else if ("toString".equals(method.getName())) {
propertyNames.put(m, propName);

if (!knownCollections.containsKey(returnType) && returnType.isInterface()) {
invoker = createInterfaceProperty(propName, newProxy(returnType, propName, immutable));
invoker = createInterfaceProperty(propName, newProxy(returnType, propName, immutable), type);
} else if (m.getParameterCount() > 0) {
if (nameAnnot == null) {
throw new IllegalArgumentException("Missing @PropertyName annotation on " + m.getDeclaringClass().getName() + "#" + m.getName());
Expand Down Expand Up @@ -377,13 +376,13 @@ private static <T> Function<Object[], T> createDefaultMethodSupplier(Method meth
};
}

protected <T> MethodInvoker<T> createInterfaceProperty(String propName, final T proxy) {
LOG.debug("Creating interface property `{}` for type `{}`", propName, proxy.getClass());
protected <T> MethodInvoker<T> createInterfaceProperty(String propName, final T proxy, Class<?> targetClass) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So, basically, this method exists just so that 1) we have a neat place to log, and 2) the internal API remains symmetrical with scalar and parametrized properties?
I'm not objecting, just making sure I'm getting it :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

oh... actually now that I see it's a protected method, I likely shouldn't change the signature at all. I can move the logging outside of the method I suppose.

LOG.debug("Creating interface property `{}` for type `{}`", propName, targetClass);
return (args) -> proxy;
}

protected <T> MethodInvoker<T> createScalarProperty(final Type type, final String propName, Function<Object[], T> next) {
LOG.debug("Creating scalar property `{}` for type `{}`", propName, type.getClass());
LOG.debug("Creating scalar property `{}` for type `{}`", propName, type);
final Property<T> prop = propertyRepository.get(propName, type);
return args -> {
T value = prop.get();
Expand Down