< prev index next >

core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/general/DuplicateFlagsRule.java

Print this page




  65 
  66         private Result getResult(IItemCollection items, IPreferenceValueProvider vp) {
  67                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.VM_INFO);
  68                 if (eventAvailability != EventAvailability.AVAILABLE) {
  69                         return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.VM_INFO);
  70                 }
  71 
  72                 IItemCollection jvmInfoItems = items.apply(JdkFilters.VM_INFO);
  73 
  74                 // FIXME: Should we check if there are different jvm args in different chunks?
  75                 Set<String> args = jvmInfoItems.getAggregate(Aggregators.distinct(JdkAttributes.JVM_ARGUMENTS));
  76                 if (args != null && !args.isEmpty()) {
  77                         
  78                         Collection<ArrayList<String>> dupes = JvmInternalsDataProvider.
  79                                         checkDuplicates(args.iterator().next());
  80 
  81                         if (!dupes.isEmpty()) {
  82                                 StringBuilder sb = new StringBuilder();
  83                                 sb.append("<ul>"); //$NON-NLS-1$
  84                                 for (ArrayList<String> dupe : dupes) {
  85                                         sb.append("<li>" + Encode.forHtml(StringToolkit.join(dupe, ", ")) + "</li>"); //$NON-NLS-1$ //$NON-NLS-2$
  86                                 }
  87                                 sb.append("</ul>"); //$NON-NLS-1$
  88                                 String shortDescription = dupes.size() > 1
  89                                                 ? MessageFormat.format(Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_WARN),
  90                                                                 dupes.size())
  91                                                 : Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_WARN_SINGULAR);
  92                                 String longDescription = shortDescription + " " + MessageFormat //$NON-NLS-1$
  93                                                 .format(Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_WARN_LONG), sb.toString());
  94                                 return new Result(this, 50, shortDescription, longDescription, JdkQueries.VM_INFO);
  95                         }
  96                 }
  97                 return new Result(this, 0, Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_OK));
  98         }
  99 
 100         @Override
 101         public RunnableFuture<Result> evaluate(final IItemCollection items, final IPreferenceValueProvider valueProvider) {
 102                 FutureTask<Result> evaluationTask = new FutureTask<>(new Callable<Result>() {
 103                         @Override
 104                         public Result call() throws Exception {
 105                                 return getResult(items, valueProvider);




  65 
  66         private Result getResult(IItemCollection items, IPreferenceValueProvider vp) {
  67                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.VM_INFO);
  68                 if (eventAvailability != EventAvailability.AVAILABLE) {
  69                         return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.VM_INFO);
  70                 }
  71 
  72                 IItemCollection jvmInfoItems = items.apply(JdkFilters.VM_INFO);
  73 
  74                 // FIXME: Should we check if there are different jvm args in different chunks?
  75                 Set<String> args = jvmInfoItems.getAggregate(Aggregators.distinct(JdkAttributes.JVM_ARGUMENTS));
  76                 if (args != null && !args.isEmpty()) {
  77                         
  78                         Collection<ArrayList<String>> dupes = JvmInternalsDataProvider.
  79                                         checkDuplicates(args.iterator().next());
  80 
  81                         if (!dupes.isEmpty()) {
  82                                 StringBuilder sb = new StringBuilder();
  83                                 sb.append("<ul>"); //$NON-NLS-1$
  84                                 for (ArrayList<String> dupe : dupes) {
  85                                         sb.append("<li>" + Encode.forHtml(StringToolkit.join(dupe, ", ")) + "</li>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  86                                 }
  87                                 sb.append("</ul>"); //$NON-NLS-1$
  88                                 String shortDescription = dupes.size() > 1
  89                                                 ? MessageFormat.format(Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_WARN),
  90                                                                 dupes.size())
  91                                                 : Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_WARN_SINGULAR);
  92                                 String longDescription = shortDescription + " " + MessageFormat //$NON-NLS-1$
  93                                                 .format(Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_WARN_LONG), sb.toString());
  94                                 return new Result(this, 50, shortDescription, longDescription, JdkQueries.VM_INFO);
  95                         }
  96                 }
  97                 return new Result(this, 0, Messages.getString(Messages.DuplicateFlagsRuleFactory_TEXT_OK));
  98         }
  99 
 100         @Override
 101         public RunnableFuture<Result> evaluate(final IItemCollection items, final IPreferenceValueProvider valueProvider) {
 102                 FutureTask<Result> evaluationTask = new FutureTask<>(new Callable<Result>() {
 103                         @Override
 104                         public Result call() throws Exception {
 105                                 return getResult(items, valueProvider);


< prev index next >