You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
palantir-java-format: case null, default com.palantir.javaformat.java.FormatterException: 146:19: error: expected token: 'default';
step palantir-java-format: found problem in
/my-class-path//SomeConsumer.java
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to format file /my-class-path//SomeConsumer.java
at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:73)
at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
Caused by: com.diffplug.spotless.ThrowingEx$WrappedAsRuntimeException: com.palantir.javaformat.java.FormatterException: 146:19: error: expected token: 'default'; generated - instead
at com.diffplug.spotless.ThrowingEx.asRuntimeRethrowError (ThrowingEx.java:133)
at com.diffplug.spotless.FormatExceptionPolicyStrict.handleError (FormatExceptionPolicyStrict.java:54)
at com.diffplug.spotless.Formatter.compute (Formatter.java:261)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:203)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:190)
at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:63)
at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
Caused by: com.palantir.javaformat.java.FormatterException: 146:19: error: expected token: 'default'; generated - instead
at com.palantir.javaformat.java.Formatter.getFormatReplacements (Formatter.java:302)
at com.palantir.javaformat.java.Formatter.formatSource (Formatter.java:277)
at com.palantir.javaformat.java.Formatter.formatSource (Formatter.java:245)
at com.diffplug.spotless.glue.pjf.PalantirJavaFormatFormatterFunc.apply (PalantirJavaFormatFormatterFunc.java:55)
at com.diffplug.spotless.FormatterFunc.apply (FormatterFunc.java:32)
at com.diffplug.spotless.FormatterStepImpl$Standard.format (FormatterStepImpl.java:82)
at com.diffplug.spotless.FormatterStep$Strict.format (FormatterStep.java:103)
at com.diffplug.spotless.Formatter.compute (Formatter.java:246)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:203)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:190)
at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:63)
at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
The text was updated successfully, but these errors were encountered:
egbemichael
changed the title
palantir-java-format not working on case null, default -> ...
palantir-java-format not working on switch case null, default -> ...
Jun 20, 2024
Do mvn spotless:apply on the following piece of code to reproduce the error
public class Test {
enum Mode {
OK,
NOK
}
public static void test1(Mode value) {
switch (value) {
case OK -> System.out.println("OK");
case NOK -> System.out.println("NOK");
case null, default -> System.out.println("Failed");
}
}
}
I just came here to report this issue, but since it seems like there are three existing duplicates, then I'll just add my comment rather than add yet another ticket :)
I see #1132 was also recently raised for a similar reason - it'd be great to see movement on some of these issues with Java 23 being released tomorrow.
palantir-java-format: case null, default com.palantir.javaformat.java.FormatterException: 146:19: error: expected token: 'default';
step palantir-java-format: found problem in
/my-class-path//SomeConsumer.java
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to format file /my-class-path//SomeConsumer.java
at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:73)
at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
Caused by: com.diffplug.spotless.ThrowingEx$WrappedAsRuntimeException: com.palantir.javaformat.java.FormatterException: 146:19: error: expected token: 'default'; generated - instead
at com.diffplug.spotless.ThrowingEx.asRuntimeRethrowError (ThrowingEx.java:133)
at com.diffplug.spotless.FormatExceptionPolicyStrict.handleError (FormatExceptionPolicyStrict.java:54)
at com.diffplug.spotless.Formatter.compute (Formatter.java:261)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:203)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:190)
at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:63)
at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
Caused by: com.palantir.javaformat.java.FormatterException: 146:19: error: expected token: 'default'; generated - instead
at com.palantir.javaformat.java.Formatter.getFormatReplacements (Formatter.java:302)
at com.palantir.javaformat.java.Formatter.formatSource (Formatter.java:277)
at com.palantir.javaformat.java.Formatter.formatSource (Formatter.java:245)
at com.diffplug.spotless.glue.pjf.PalantirJavaFormatFormatterFunc.apply (PalantirJavaFormatFormatterFunc.java:55)
at com.diffplug.spotless.FormatterFunc.apply (FormatterFunc.java:32)
at com.diffplug.spotless.FormatterStepImpl$Standard.format (FormatterStepImpl.java:82)
at com.diffplug.spotless.FormatterStep$Strict.format (FormatterStep.java:103)
at com.diffplug.spotless.Formatter.compute (Formatter.java:246)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:203)
at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:190)
at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:63)
at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572)
at java.util.concurrent.FutureTask.run (FutureTask.java:317)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642)
at java.lang.Thread.run (Thread.java:1583)
The text was updated successfully, but these errors were encountered: