[SYNCOPE-1327] Build works fine with Java 10 and Java 8
authorFrancesco Chicchiriccò <ilgrosso@apache.org>
Fri, 29 Jun 2018 11:19:58 +0000 (13:19 +0200)
committerFrancesco Chicchiriccò <ilgrosso@apache.org>
Fri, 29 Jun 2018 14:29:07 +0000 (16:29 +0200)
21 files changed:
client/cli/src/main/java/org/apache/syncope/client/cli/Input.java
client/cli/src/main/java/org/apache/syncope/client/cli/SyncopeAdm.java
client/cli/src/main/java/org/apache/syncope/client/cli/commands/help/Help.java
client/cli/src/main/java/org/apache/syncope/client/cli/util/CommandUtils.java
client/cli/src/test/java/org/apache/syncope/client/cli/util/CommandUtilsTest.java
client/console/src/main/java/org/apache/syncope/client/console/panels/ImplementationModalPanel.java
client/console/src/main/java/org/apache/syncope/client/console/panels/SchemaTypePanel.java
client/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskDirectoryPanel.java
client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java
client/lib/pom.xml
client/lib/src/test/java/org/apache/syncope/client/lib/ConcurrencyTest.java
common/lib/pom.xml
common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeFiqlParser.java
common/rest-api/pom.xml
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPATaskUtils.java
core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/XMLContentExporterTest.java
ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/producer/StatusProducer.java
ext/scimv2/scim-rest-api/pom.xml
fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConnectorITCase.java
installer/src/main/java/org/apache/syncope/installer/utilities/DriverLoader.java
pom.xml

index 2e86c08..0290902 100644 (file)
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.client.cli;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -44,7 +45,8 @@ public class Input {
     private String option;
 
     public Input(final String[] args)
-            throws InstantiationException, IllegalAccessException, IllegalArgumentException {
+            throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+            NoSuchMethodException, InvocationTargetException {
 
         command = CommandUtils.fromArgs(args[0]);
         commandFields.add(args[0]);
index 175040e..8a75f75 100644 (file)
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.client.cli;
 
+import java.lang.reflect.InvocationTargetException;
 import javax.ws.rs.ProcessingException;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.syncope.client.cli.commands.AbstractCommand;
@@ -49,7 +50,9 @@ public final class SyncopeAdm {
             System.out.println("");
             System.out.println("You are running: " + input.printCommandFields());
             command.execute(input);
-        } catch (final IllegalAccessException | InstantiationException e) {
+        } catch (IllegalAccessException | InstantiationException | NoSuchMethodException
+                | InvocationTargetException e) {
+
             System.out.println(helpMessage());
         } catch (final IllegalArgumentException ex) {
             LOG.error("Error in main", ex);
@@ -79,9 +82,9 @@ public final class SyncopeAdm {
                 }
                 helpMessageBuilder.append("\n");
             }
-        } catch (final IllegalAccessException | IllegalArgumentException | InstantiationException ex) {
-            LOG.error("Error in main", ex);
-            RESULT_MANAGER.genericError(ex.getMessage());
+        } catch (Exception e) {
+            LOG.error("Error in main", e);
+            RESULT_MANAGER.genericError(e.getMessage());
         }
 
         return helpMessageBuilder.toString();
index 41f908b..516ad3c 100644 (file)
@@ -42,7 +42,7 @@ public class Help {
                         .append(" \n");
             }
             helpResultManager.toView(generalHelpBuilder.toString());
-        } catch (final IllegalAccessException | IllegalArgumentException | InstantiationException e) {
+        } catch (Exception e) {
             LOG.error("Error helping", e);
             helpResultManager.genericMessage(e.getMessage());
         }
index 01703ca..b1b6db4 100644 (file)
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.client.cli.util;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.syncope.client.cli.Command;
@@ -27,7 +28,8 @@ import org.apache.syncope.client.cli.commands.AbstractCommand;
 public final class CommandUtils {
 
     public static AbstractCommand fromArgs(final String arg)
-            throws InstantiationException, IllegalAccessException, IllegalArgumentException {
+            throws NoSuchMethodException, InstantiationException, IllegalAccessException,
+            IllegalArgumentException, InvocationTargetException {
 
         final CommandClassScanner ccs = new CommandClassScanner();
         final List<Class<? extends AbstractCommand>> commands = ccs.getComponentClasses();
@@ -43,11 +45,12 @@ public final class CommandUtils {
             throw new IllegalArgumentException(arg + " is not a valid command");
         }
 
-        return commandClass.newInstance();
+        return commandClass.getDeclaredConstructor().newInstance();
     }
 
     public static List<AbstractCommand> commands()
-            throws InstantiationException, IllegalAccessException, IllegalArgumentException {
+            throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+            NoSuchMethodException, InvocationTargetException {
 
         final List<AbstractCommand> listCommands = new ArrayList<>();
 
@@ -58,7 +61,7 @@ public final class CommandUtils {
             if (cmd == null) {
                 throw new IllegalArgumentException();
             }
-            listCommands.add(cmd.newInstance());
+            listCommands.add(cmd.getDeclaredConstructor().newInstance());
         }
 
         return listCommands;
index a1e4ee5..558b802 100644 (file)
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.fail;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import org.apache.syncope.client.cli.Command;
 import org.apache.syncope.client.cli.commands.AbstractCommand;
@@ -30,7 +31,9 @@ import org.junit.jupiter.api.Test;
 public class CommandUtilsTest {
 
     @Test
-    public void fromArgs() throws InstantiationException, IllegalAccessException {
+    public void fromArgs() throws InstantiationException, IllegalAccessException,
+            NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
+
         String commandName = "logger";
         AbstractCommand command = CommandUtils.fromArgs(commandName);
         assertEquals(commandName, command.getClass().getAnnotation(Command.class).name());
@@ -46,7 +49,9 @@ public class CommandUtilsTest {
     }
 
     @Test
-    public void commands() throws InstantiationException, IllegalAccessException {
+    public void commands() throws InstantiationException, IllegalAccessException,
+            NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
+
         List<AbstractCommand> commands = CommandUtils.commands();
         assertFalse(commands.isEmpty());
         assertEquals(22, commands.size());
index 5f3fdae..e266981 100644 (file)
@@ -295,7 +295,7 @@ public class ImplementationModalPanel extends AbstractModalPanel<ImplementationT
                 if (clazz != null) {
                     try {
                         target.appendJavaScript("editor.getDoc().setValue('"
-                                + MAPPER.writeValueAsString(clazz.newInstance())
+                                + MAPPER.writeValueAsString(clazz.getDeclaredConstructor().newInstance())
                                 + "');");
                     } catch (Exception e) {
                         LOG.error("Could not generate a value for {}", jsonClass.getModelObject(), e);
index e3737ec..1ced1aa 100644 (file)
@@ -89,8 +89,9 @@ public class SchemaTypePanel extends TypesDirectoryPanel<SchemaTO, SchemaProvide
         disableCheckBoxes();
 
         try {
-            addNewItemPanelBuilder(new SchemaTypeWizardBuilder(schemaType.getToClass().newInstance(), pageRef), true);
-        } catch (IllegalAccessException | InstantiationException e) {
+            addNewItemPanelBuilder(new SchemaTypeWizardBuilder(
+                    schemaType.getToClass().getDeclaredConstructor().newInstance(), pageRef), true);
+        } catch (Exception e) {
             LOG.error("Error creating instance of {}", schemaType, e);
         }
 
index ed2f7c2..70170c2 100644 (file)
@@ -93,8 +93,8 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
         this.reference = reference;
 
         try {
-            schedTaskTO = reference.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            schedTaskTO = reference.getDeclaredConstructor().newInstance();
+        } catch (Exception e) {
             LOG.error("Falure instantiating task", e);
         }
 
index f918d30..f1f6b3a 100644 (file)
@@ -203,7 +203,7 @@ public class SyncopeEnduserApplication extends WebApplication implements Seriali
                 LOG.debug("No @Resource annotation found on {}, ignoring", resource.getName());
             } else {
                 try {
-                    final AbstractResource instance = resource.newInstance();
+                    final AbstractResource instance = resource.getDeclaredConstructor().newInstance();
 
                     mountResource(annotation.path(), new ResourceReference(annotation.key()) {
 
index 71a75c4..d34595d 100644 (file)
@@ -39,11 +39,6 @@ under the License.
   
   <dependencies>
     <dependency>
-      <groupId>javax.ws.rs</groupId>
-      <artifactId>javax.ws.rs-api</artifactId>
-    </dependency>
-
-    <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-rt-rs-client</artifactId>
     </dependency>
index f993504..7910b5f 100644 (file)
@@ -32,12 +32,10 @@ public class ConcurrencyTest {
 
     private static final int THREAD_NUMBER = 1000;
 
-    private static final SyncopeClient client = new SyncopeClientFactoryBean().setAddress("http://url").create();
+    private static final SyncopeClient CLIENT = new SyncopeClientFactoryBean().setAddress("http://url").create();
 
     @Test
-    public void multiThreadTest()
-            throws InterruptedException {
-
+    public void multiThreadTest() throws InterruptedException {
         for (int i = 0; i < THREAD_NUMBER; i++) {
             Thread execution = new Thread("Th-" + StringUtils.leftPad(String.valueOf(i), 5, '0')) {
 
@@ -45,7 +43,7 @@ public class ConcurrencyTest {
                 public void run() {
 
                     try {
-                        client.getService(ResourceService.class);
+                        CLIENT.getService(ResourceService.class);
 
                         LOG.info(getName() + " completed successfully!");
                     } catch (Exception e) {
@@ -67,7 +65,7 @@ public class ConcurrencyTest {
     public void multiCallTest() {
         try {
             for (int i = 0; i < THREAD_NUMBER; i++) {
-                client.getService(ResourceService.class);
+                CLIENT.getService(ResourceService.class);
             }
         } catch (Exception e) {
             fail(e.getMessage());
index 82d5c72..d5c99a9 100644 (file)
@@ -39,11 +39,6 @@ under the License.
 
   <dependencies>
     <dependency>
-      <groupId>javax.ws.rs</groupId>
-      <artifactId>javax.ws.rs-api</artifactId>
-    </dependency>
-    
-    <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-rt-rs-extension-search</artifactId>
     </dependency>
index dc3c5ae..fa15736 100644 (file)
@@ -139,7 +139,7 @@ public class SyncopeFiqlParser<T> extends FiqlParser<T> {
                     beanspector.instantiate().setValue(setter, tvalue.getObject());
                     return beanspector.getBean();
                 } else {
-                    SearchBean bean = (SearchBean) conditionClass.newInstance();
+                    SearchBean bean = (SearchBean) conditionClass.getDeclaredConstructor().newInstance();
                     bean.set(setter, tvalue.getObject().toString());
                     return (T) bean;
                 }
index 717afc9..70ea48d 100644 (file)
@@ -44,11 +44,6 @@ under the License.
     </dependency>
 
     <dependency>
-      <groupId>javax.ws.rs</groupId>
-      <artifactId>javax.ws.rs-api</artifactId>
-    </dependency>
-
-    <dependency>
       <groupId>org.apache.syncope.common</groupId>
       <artifactId>syncope-common-lib</artifactId>
       <version>${project.version}</version>
index 3f9c720..0d83523 100644 (file)
@@ -144,7 +144,7 @@ public final class JPATaskUtils implements TaskUtils {
     public <T extends TaskTO> T newTaskTO() {
         final Class<T> taskClass = taskTOClass();
         try {
-            return taskClass == null ? null : taskClass.newInstance();
+            return taskClass == null ? null : taskClass.getDeclaredConstructor().newInstance();
         } catch (Exception e) {
             return null;
         }
index 03a5313..7f2297c 100644 (file)
@@ -55,12 +55,11 @@ public class XMLContentExporterTest extends AbstractTest {
 
         List<String> realms = IOUtils.readLines(
                 IOUtils.toInputStream(exported, Charset.defaultCharset()), Charset.defaultCharset()).stream().
-                filter(row -> row.startsWith("<REALM")).collect(Collectors.toList());
+                filter(row -> row.trim().startsWith("<REALM")).collect(Collectors.toList());
         assertEquals(4, realms.size());
         assertTrue(realms.get(0).contains("NAME=\"/\""));
         assertTrue(realms.get(1).contains("NAME=\"odd\""));
         assertTrue(realms.get(2).contains("NAME=\"even\""));
         assertTrue(realms.get(3).contains("NAME=\"two\""));
     }
-
 }
index 96983a4..6aae0a7 100644 (file)
@@ -86,7 +86,7 @@ public class StatusProducer extends AbstractProducer {
                 }
             }
         } else if (getAnyTypeKind() == AnyTypeKind.USER) {
-            WorkflowResult<Long> updated = (WorkflowResult<Long>) exchange.getIn().getBody();
+            WorkflowResult<String> updated = (WorkflowResult<String>) exchange.getIn().getBody();
             StatusPatch statusPatch = exchange.getProperty("statusPatch", StatusPatch.class);
             Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
 
@@ -105,5 +105,4 @@ public class StatusProducer extends AbstractProducer {
             exchange.getOut().setBody(Pair.of(updated.getResult(), propagationReporter.getStatuses()));
         }
     }
-
 }
index 1f8d8d6..c605266 100644 (file)
@@ -44,11 +44,6 @@ under the License.
     </dependency>
 
     <dependency>
-      <groupId>javax.ws.rs</groupId>
-      <artifactId>javax.ws.rs-api</artifactId>
-    </dependency>
-    
-    <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-annotations</artifactId>
     </dependency>
index 0ac4692..64cab1a 100644 (file)
@@ -452,15 +452,15 @@ public class ConnectorITCase extends AbstractITCase {
 
     @Test
     public void buildObjectClassInfo() {
-        ConnInstanceTO ws = connectorService.read(
-                "5ffbb4ac-a8c3-4b44-b699-11b398a1ba08", Locale.ENGLISH.getLanguage());
-        assertNotNull(ws);
+        ConnInstanceTO db = connectorService.read(
+                "5aa5b8be-7521-481a-9651-c557aea078c1", Locale.ENGLISH.getLanguage());
+        assertNotNull(db);
 
-        List<ConnIdObjectClassTO> objectClassInfo = connectorService.buildObjectClassInfo(ws, true);
+        List<ConnIdObjectClassTO> objectClassInfo = connectorService.buildObjectClassInfo(db, true);
         assertNotNull(objectClassInfo);
         assertEquals(1, objectClassInfo.size());
         assertEquals(ObjectClass.ACCOUNT_NAME, objectClassInfo.get(0).getType());
-        assertTrue(objectClassInfo.get(0).getAttributes().contains("promoThirdPartyDisclaimer"));
+        assertTrue(objectClassInfo.get(0).getAttributes().contains("ID"));
 
         ConnInstanceTO ldap = connectorService.read(
                 "74141a3b-0762-4720-a4aa-fc3e374ef3ef", Locale.ENGLISH.getLanguage());
index 8564c41..81229b2 100644 (file)
@@ -28,13 +28,13 @@ import java.sql.Driver;
 public final class DriverLoader extends URLClassLoader {
 
     private static final String POSTGRES_JAR =
-            "http://repo1.maven.org/maven2/postgresql/postgresql/9.1-901.jdbc4/postgresql-9.1-901.jdbc4.jar";
+            "http://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.2/postgresql-42.2.2.jar";
 
     private static final String MYSQL_JAR =
-            "http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar";
+            "http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.46/mysql-connector-java-5.1.46.jar";
 
     private static final String MARIADB_JAR =
-            "http://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/1.1.8/mariadb-java-client-1.1.8.jar";
+            "http://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.2.5/mariadb-java-client-2.2.5.jar";
 
     private static final String POSTGRES_CLASS_DRIVER = "org.postgresql.Driver";
 
@@ -97,9 +97,8 @@ public final class DriverLoader extends URLClassLoader {
                     System.setProperty("http.proxyPassword", proxyPwd);
                 }
             }
-            final URL[] url = { new URL(driverUrl) };
-            DRIVER_LOADER = new DriverLoader(url);
-            driver = (Driver) DRIVER_LOADER.loadClass(driverClassName).newInstance();
+            DRIVER_LOADER = new DriverLoader(new URL[] { new URL(driverUrl) });
+            driver = (Driver) DRIVER_LOADER.loadClass(driverClassName).getDeclaredConstructor().newInstance();
         } catch (Exception e) {
             // ignore
         }
diff --git a/pom.xml b/pom.xml
index 8dad5ea..4783846 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -533,11 +533,6 @@ under the License.
         <scope>provided</scope>
       </dependency>
       <dependency>
-        <groupId>javax.ws.rs</groupId>
-        <artifactId>javax.ws.rs-api</artifactId>
-        <version>2.1</version>
-      </dependency>
-      <dependency>
         <groupId>org.apache.geronimo.javamail</groupId>
         <artifactId>geronimo-javamail_1.4_mail</artifactId>
         <version>1.8.4</version>
@@ -2584,6 +2579,46 @@ under the License.
       </modules>
     </profile>
     
+    <profile>
+      <id>java9-plus</id>
+
+      <activation>
+        <jdk>[9,)</jdk>
+      </activation>
+
+      <dependencies>
+        <dependency>
+          <groupId>javax.xml.bind</groupId>
+          <artifactId>jaxb-api</artifactId>
+          <version>2.3.0</version>
+        </dependency>
+        <dependency>
+          <groupId>com.sun.xml.bind</groupId>
+          <artifactId>jaxb-core</artifactId>
+          <version>2.3.0.1</version>
+        </dependency>
+        <dependency>
+          <groupId>com.sun.xml.bind</groupId>
+          <artifactId>jaxb-impl</artifactId>
+          <version>2.3.0.1</version>
+        </dependency>
+        <dependency>
+          <groupId>javax.annotation</groupId>
+          <artifactId>javax.annotation-api</artifactId>
+          <version>1.3.1</version>
+        </dependency>
+        <dependency>
+          <groupId>javax.xml.ws</groupId>
+          <artifactId>jaxws-api</artifactId>
+          <version>2.3.0</version>
+        </dependency>
+        <dependency>
+          <groupId>javax.activation</groupId>
+          <artifactId>activation</artifactId>
+          <version>1.1.1</version>
+        </dependency>
+      </dependencies>
+    </profile>
   </profiles>
   
   <modules>