Hi

we should just replace runtimeexception we our own runtimeexceptions
'OpenEJBRuntimeException or tomee one.

About the issue itself isn't it cause the line separator is wrongly configured?

Testing the string and its reversed looks like a hack, no?

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-04 16:39 GMT+02:00  <[email protected]>:
> Author: andygumbrecht
> Date: Fri Apr  4 14:39:52 2014
> New Revision: 1584720
>
> URL: http://svn.apache.org/r1584720
> Log:
> Console buffer can return chars in reverse.
> Check file ops.
>
> Modified:
>     
> tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
>
> Modified: 
> tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
> URL: 
> http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java?rev=1584720&r1=1584719&r2=1584720&view=diff
> ==============================================================================
> --- 
> tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
>  (original)
> +++ 
> tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
>  Fri Apr  4 14:39:52 2014
> @@ -749,13 +749,12 @@ public abstract class AbstractTomEEMojo
>
>                  String line;
>                  while ((line = reader.nextLine()) != null) {
> -                    if (QUIT_CMD.equalsIgnoreCase(line) || 
> EXIT_CMD.equalsIgnoreCase(line)) {
> -                        break;
> -                    }
>
>                      if (!handleLine(line.trim())) {
>                          System.out.flush();
>                          getLog().warn("Command '" + line + "' not 
> understood. Use one of " + availableCommands());
> +                    } else {
> +                        break;
>                      }
>                  }
>
> @@ -881,8 +880,15 @@ public abstract class AbstractTomEEMojo
>          stopCondition.countDown();
>      }
>
> -    protected boolean handleLine(final String line) {
> -        return false;
> +    protected boolean handleLine(String line) {
> +        if (QUIT_CMD.equalsIgnoreCase(line) || 
> EXIT_CMD.equalsIgnoreCase(line)) {
> +            return true;
> +        }
> +
> +        //Command line can buffer chars fifo 'tiuq'
> +        line = new StringBuilder(line).reverse().toString();
> +
> +        return QUIT_CMD.equalsIgnoreCase(line) || 
> EXIT_CMD.equalsIgnoreCase(line);
>      }
>
>      protected void serverCmd(final RemoteServer server, final List<String> 
> strings) {
> @@ -929,7 +935,7 @@ public abstract class AbstractTomEEMojo
>          }
>
>          if ((tomeeClassifier != null && (tomeeClassifier.isEmpty() || 
> tomeeClassifier.equals("ignore")))
> -                || ("org.apache.openejb".equals(tomeeGroupId) && 
> "openejb-standalone".equals(tomeeArtifactId))) {
> +            || ("org.apache.openejb".equals(tomeeGroupId) && 
> "openejb-standalone".equals(tomeeArtifactId))) {
>              tomeeClassifier = null;
>          }
>
> @@ -965,12 +971,16 @@ public abstract class AbstractTomEEMojo
>                  final File dest = new File(catalinaBase.getAbsolutePath(), 
> name);
>                  if (!dest.exists()) {
>                      final File parent = dest.getParentFile();
> -                    parent.mkdirs();
> -                    parent.setWritable(true);
> -                    parent.setReadable(true);
> +                    if ((!parent.exists() && !parent.mkdirs())
> +                        || (!parent.canWrite() && !parent.setWritable(true))
> +                        || (!parent.canRead() && !parent.setReadable(true))) 
> {
> +                        throw new RuntimeException("Failed to create or set 
> permissions on: " + parent);
> +                    }
>                  }
>                  if (entry.isDirectory()) {
> -                    dest.mkdir();
> +                    if (!dest.exists() && !dest.mkdir()) {
> +                        throw new RuntimeException("Failed to create: " + 
> dest);
> +                    }
>                  } else {
>                      final FileOutputStream fos = new FileOutputStream(dest);
>                      try {
> @@ -980,9 +990,13 @@ public abstract class AbstractTomEEMojo
>                      }
>                      close(fos);
>
> -                    dest.setReadable(true);
> +                    if (!dest.canRead() && !dest.setReadable(true)) {
> +                        throw new RuntimeException("Failed to set readable 
> on: " + dest);
> +                    }
>                      if (dest.getName().endsWith(".sh")) {
> -                        dest.setExecutable(true);
> +                        if (!dest.canExecute() && !dest.setExecutable(true)) 
> {
> +                            throw new RuntimeException("Failed to set 
> executable on: " + dest);
> +                        }
>                      }
>                  }
>              }
> @@ -1007,8 +1021,8 @@ public abstract class AbstractTomEEMojo
>              writer.close();
>
>              final File appsFolder = new File(catalinaBase, "apps");
> -            if (!appsFolder.exists()) {
> -                appsFolder.mkdirs();
> +            if (!appsFolder.exists() && !appsFolder.mkdirs()) {
> +                throw new RuntimeException("Failed to create: " + 
> appsFolder);
>              }
>
>              getLog().info(container + " was unzipped in '" + 
> catalinaBase.getAbsolutePath() + "'");
>
>

Reply via email to