Skip to content

Commit

Permalink
codecy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amakwana committed Apr 16, 2020
1 parent 3fe8ef5 commit 9ac9208
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ElideResourceConfig extends ResourceConfig {

private static MetricRegistry metricRegistry = null;
private static HealthCheckRegistry healthCheckRegistry = null;
private static ElideDynamicEntityCompiler dynamicEntityCompiler;
private ElideDynamicEntityCompiler dynamicEntityCompiler = null;

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,21 @@
@Slf4j
public class ElideDynamicEntityCompiler {

public static List<String> classNames = new ArrayList<String>();

@SuppressWarnings("rawtypes")
public static Set<Class> bindClasses;

public static final String PACKAGE_NAME = "com.yahoo.elide.contrib.dynamicconfig.model.";
private Map<String, Class<?>> compiledObjects;
public static List<String> classNames = new ArrayList<String>();

InMemoryJavaCompiler compiler = InMemoryJavaCompiler.newInstance();
private static InMemoryJavaCompiler inMemoryJavaCompiler = InMemoryJavaCompiler.newInstance();
private static HandlebarsHydrator handlebarHydrator = new HandlebarsHydrator();
private static ElideConfigParser elideConfigParser = new ElideConfigParser();
private static Map<String, Class<?>> compiledObjects;

HandlebarsHydrator hydrator = new HandlebarsHydrator();
ElideConfigParser elideConfigParser = new ElideConfigParser();
ElideTableConfig tableConfig = new ElideTableConfig();
ElideSecurityConfig securityConfig = new ElideSecurityConfig();
private ElideTableConfig tableConfig = new ElideTableConfig();
private ElideSecurityConfig securityConfig = new ElideSecurityConfig();

Map<String, String> tableClasses = new HashMap<String, String>();
Map<String, String> securityClasses = new HashMap<String, String>();
private Map<String, String> tableClasses = new HashMap<String, String>();
private Map<String, String> securityClasses = new HashMap<String, String>();

/**
* generate java classes from dynamic config.
Expand All @@ -56,8 +54,8 @@ public ElideDynamicEntityCompiler(String path) {

tableConfig = elideConfigParser.getElideTableConfig();
securityConfig = elideConfigParser.getElideSecurityConfig();
tableClasses = hydrator.hydrateTableTemplate(tableConfig);
securityClasses = hydrator.hydrateSecurityTemplate(securityConfig);
tableClasses = handlebarHydrator.hydrateTableTemplate(tableConfig);
securityClasses = handlebarHydrator.hydrateSecurityTemplate(securityConfig);

for (Entry<String, String> entry : tableClasses.entrySet()) {
classNames.add(PACKAGE_NAME + entry.getKey());
Expand All @@ -67,7 +65,7 @@ public ElideDynamicEntityCompiler(String path) {
classNames.add(PACKAGE_NAME + entry.getKey());
}

compiler.useParentClassLoader(
inMemoryJavaCompiler.useParentClassLoader(
new ElideDynamicInMemoryClassLoader(ClassLoader.getSystemClassLoader(),
Sets.newHashSet(classNames)));

Expand All @@ -85,14 +83,14 @@ public void compile() {
try {
for (Map.Entry<String, String> tablePojo : tableClasses.entrySet()) {
log.info("key: " + PACKAGE_NAME + tablePojo.getKey() + ", value: " + tablePojo.getValue());
compiler.addSource(PACKAGE_NAME + tablePojo.getKey(), tablePojo.getValue());
inMemoryJavaCompiler.addSource(PACKAGE_NAME + tablePojo.getKey(), tablePojo.getValue());
}

for (Map.Entry<String, String> secPojo : securityClasses.entrySet()) {
log.info("key: " + PACKAGE_NAME + secPojo.getKey() + ", value: " + secPojo.getValue());
compiler.addSource(PACKAGE_NAME + secPojo.getKey(), secPojo.getValue());
inMemoryJavaCompiler.addSource(PACKAGE_NAME + secPojo.getKey(), secPojo.getValue());
}
compiledObjects = compiler.compileAll();
compiledObjects = inMemoryJavaCompiler.compileAll();
} catch (Exception e) {
log.error("Unable to compile dynamic classes");
}
Expand All @@ -103,7 +101,7 @@ public void compile() {
* @return ClassLoader
*/
public ClassLoader getClassLoader() {
return compiler.getClassloader();
return inMemoryJavaCompiler.getClassloader();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Post {
@Column(nullable = false)
private String content;

@Temporal( TemporalType.TIMESTAMP )
@Temporal (TemporalType.TIMESTAMP)
private Date date;

@CreatePermission(expression = AdminCheck.USER_IS_ADMIN)
Expand Down

0 comments on commit 9ac9208

Please sign in to comment.