From 9ac9208e304f151664b6577c7d6f89654327d4d0 Mon Sep 17 00:00:00 2001 From: amakwana Date: Thu, 16 Apr 2020 01:29:48 -0400 Subject: [PATCH] codecy issues --- .../config/ElideResourceConfig.java | 2 +- .../config/ElideDynamicEntityCompiler.java | 34 +++++++++---------- .../yahoo/elide/standalone/models/Post.java | 2 +- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java b/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java index 32ce8ce20f..ea3c6eb1b7 100644 --- a/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java +++ b/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java @@ -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. diff --git a/elide-standalone/src/main/java/com/yahoo/elide/standalone/dynamic/config/ElideDynamicEntityCompiler.java b/elide-standalone/src/main/java/com/yahoo/elide/standalone/dynamic/config/ElideDynamicEntityCompiler.java index 4e27705cfa..493d3de13c 100644 --- a/elide-standalone/src/main/java/com/yahoo/elide/standalone/dynamic/config/ElideDynamicEntityCompiler.java +++ b/elide-standalone/src/main/java/com/yahoo/elide/standalone/dynamic/config/ElideDynamicEntityCompiler.java @@ -28,23 +28,21 @@ @Slf4j public class ElideDynamicEntityCompiler { - public static List classNames = new ArrayList(); - @SuppressWarnings("rawtypes") public static Set bindClasses; - public static final String PACKAGE_NAME = "com.yahoo.elide.contrib.dynamicconfig.model."; - private Map> compiledObjects; + public static List classNames = new ArrayList(); - 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> 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 tableClasses = new HashMap(); - Map securityClasses = new HashMap(); + private Map tableClasses = new HashMap(); + private Map securityClasses = new HashMap(); /** * generate java classes from dynamic config. @@ -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 entry : tableClasses.entrySet()) { classNames.add(PACKAGE_NAME + entry.getKey()); @@ -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))); @@ -85,14 +83,14 @@ public void compile() { try { for (Map.Entry 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 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"); } @@ -103,7 +101,7 @@ public void compile() { * @return ClassLoader */ public ClassLoader getClassLoader() { - return compiler.getClassloader(); + return inMemoryJavaCompiler.getClassloader(); } /** diff --git a/elide-standalone/src/test/java/com/yahoo/elide/standalone/models/Post.java b/elide-standalone/src/test/java/com/yahoo/elide/standalone/models/Post.java index cd59f3daaa..7da76a74ab 100644 --- a/elide-standalone/src/test/java/com/yahoo/elide/standalone/models/Post.java +++ b/elide-standalone/src/test/java/com/yahoo/elide/standalone/models/Post.java @@ -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)