Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

PROC-1198: Only use public static methods in EL FunctionMapper #96

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Lifecycle](https://img.shields.io/osslifecycle/indeedeng/proctor.svg)

Proctor is a A/B testing framework written in Java that enables [data-driven product design](https://engineering.indeedblog.com/talks/data-driven-product-design/) at Indeed.
Proctor is an A/B testing framework written in Java that enables [data-driven product design](https://engineering.indeedblog.com/talks/data-driven-product-design/) at Indeed.

Proctor consists of data-model, client specification, client loader, matrix builder, java code generator.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
public class LibraryFunctionMapper extends FunctionMapper {
@Nonnull
private final Map<String, Map<String, Method>> libraries = Maps.newHashMap();
private static final int PUBLIC_AND_STATIC = Modifier.PUBLIC | Modifier.STATIC;

public LibraryFunctionMapper(@Nonnull final Map<String, Class<?>> libraryClasses) {
for (final Entry<String, Class<?>> entry : libraryClasses.entrySet()) {
Expand All @@ -31,10 +30,9 @@ private Map<String, Method> extractFunctions(@Nonnull final Class<?> c) {
final Map<String, Method> libraryFunctions = Maps.newHashMap();
for (final Method m : c.getMethods()) {
final int modifiers = m.getModifiers();
if ((modifiers & PUBLIC_AND_STATIC) == 0) {
zacharygoodwin marked this conversation as resolved.
Show resolved Hide resolved
continue;
if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)) {
libraryFunctions.put(m.getName(), m);
}
libraryFunctions.put(m.getName(), m);
}
return libraryFunctions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.lang.reflect.Method;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;


public class TestLibraryFunctionMapper {
Expand All @@ -28,5 +29,8 @@ public void testConstruction() {

final Method foundMeToo = mapper.resolveFunction(key, "findMeToo");
assertNotNull(foundMeToo);

final Method notFound = mapper.resolveFunction(key, "toString");
assertNull(notFound);
}
}