From a39a2dace9d2b76f2e7ac7c70d6f1c5643ee80ee Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Thu, 21 Jun 2007 06:18:33 +0000 Subject: [PATCH] Return gracefully when no class found for enhancement. Without this check raises NPE. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@549405 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/openjpa/enhance/PCEnhancer.java | 6 +++++- .../org/apache/openjpa/enhance/localizer.properties | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index 5ef37c7a9..040656ac0 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -3639,6 +3639,10 @@ public class PCEnhancer { if (args.length == 0) { log.info(_loc.get("running-all-classes")); classes = repos.getPersistentTypeNames(true, loader); + if (classes == null) { + log.warn(_loc.get("no-class-to-enhance")); + return false; + } } else { ClassArgParser cap = conf.getMetaDataRepositoryInstance(). getMetaDataFactory().newClassArgParser(); @@ -3647,7 +3651,7 @@ public class PCEnhancer { for (int i = 0; i < args.length; i++) classes.addAll(Arrays.asList(cap.parseTypes(args[i]))); } - + Project project = new Project(); BCClass bc; PCEnhancer enhancer; diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties index c20aeb60a..e2d44ded9 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties @@ -30,6 +30,7 @@ running-all-classes: No targets were given. Running on all classes in your \ persistent classes list, or all metadata files in classpath directories if \ you have not listed your persistent classes. Use -help to display tool \ usage information. +no-class-to-enhance: Found no class to enhance. detach-custom-ser: Type "{0}" is set to detach on serialize, but implements \ a custom readObject and/or writeObject method. You cannot use custom \ serialization with detachment.