Fix some null warnings
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 24 Nov 2015 23:50:39 +0000 (18:50 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 8 Dec 2015 19:03:38 +0000 (14:03 -0500)
Change-Id: Ib0290125def1e0ea58bcf81c2075ef99db3f1f1a
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/59428
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
100 files changed:
analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/SegmentStoreContentProvider.java
btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BtfEventType.java
btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventTypeFactory.java
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/StreamFlattener.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/IEventDeclaration.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDefinition.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderDefinition.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventType.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/stubs/org/eclipse/tracecompass/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/AssignEventHandler.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/NullControlService.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlPreferences.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/EventMatchingBenchmark.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/TraceSynchronizationBenchmark.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/MatchAndSyncTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerStatedump.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/trace/VirtualMachineExperiment.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoStateProvider.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java
pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPPacket.java
pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/unknown/UnknownPacket.java
pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventFieldTest.java
pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEvent.java
pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventField.java
pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapRootEventField.java
statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/statevalue/StateValueCompareToTest.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTree.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/TmfStateInterval.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateValue.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/AnalysisRequirementTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisModuleSources.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/ITmfMipmapFeature.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MaxMipmapFeature.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MinMipmapFeature.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisModuleOutputs.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisRequirement.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/ITmfEventProvider.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEvent.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/ITmfFilterTreeNode.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterTreeNode.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/ITmfStatistics.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStateStatistics.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/synchronization/SynchronizationManager.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java
tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandResultTest.java
tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java
tmf/org.eclipse.tracecompass.tmf.remote.core.tests/stubs/org/eclipse/tracecompass/internal/tmf/remote/core/stubs/shells/TestCommandShell.java
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandResult.java
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/TmfRemoteConnectionFactory.java
tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/model/RemoteImportProfilesReader.java
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ManifestReader.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectRootNodeWizardPage.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectTracesWizardPage.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterManager.java

index 0d5814a240ec9361aaf6da33287bd878fbac6429..70974d9286ae02b3711a14196ed2c630b418fc0a 100644 (file)
@@ -79,6 +79,9 @@ public class TmfGraphStatistics implements ITmfGraphVisitor {
         synchronized (fWorkerStats) {
             if (horizontal && graph != null) {
                 IGraphWorker worker = graph.getParentOf(edge.getVertexFrom());
+                if (worker == null) {
+                    return;
+                }
                 Long duration = edge.getDuration();
                 Long currentTotal = fWorkerStats.get(worker);
                 if (currentTotal != null) {
index dac5dcf3c45dca21cd34777f4f4926412fae38eb..aeee16c8119a663430aba119eb37b51e4d7ed4ee 100644 (file)
@@ -83,7 +83,7 @@ public class KernelAnalysisModule extends TmfStateSystemAnalysisModule {
 //        eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL);
 //
 //        REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq));
-        REQUIREMENTS = checkNotNull(Collections.EMPTY_SET);
+        REQUIREMENTS = Collections.EMPTY_SET;
     }
 
     @Override
index bf4c48363ecb0b15b4186261cf2a27521bdca72d..874020e14ca278e0085855aacc13fdfb66a4a9d4 100644 (file)
@@ -92,7 +92,7 @@ public final class KernelThreadInformationProvider {
     public static Collection<Integer> getThreadIds(KernelAnalysisModule module) {
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
-            return NonNullUtils.checkNotNull(Collections.EMPTY_SET);
+            return Collections.EMPTY_SET;
         }
         int threadQuark;
         try {
@@ -104,7 +104,7 @@ public final class KernelThreadInformationProvider {
             return tids;
         } catch (AttributeNotFoundException e) {
         }
-        return NonNullUtils.checkNotNull(Collections.EMPTY_SET);
+        return Collections.EMPTY_SET;
     }
 
     /**
@@ -245,7 +245,7 @@ public final class KernelThreadInformationProvider {
     public static List<ITmfStateInterval> getStatusIntervalsForThread(KernelAnalysisModule module, Integer threadId, long start, long end, long resolution, IProgressMonitor monitor) {
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
-            return NonNullUtils.checkNotNull(Collections.EMPTY_LIST);
+            return Collections.EMPTY_LIST;
         }
 
         try {
@@ -255,7 +255,7 @@ public final class KernelThreadInformationProvider {
             return statusIntervals;
         } catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
         }
-        return NonNullUtils.checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
 }
index c949c04de761bfb623c327111f15e8b97e4b0577..06d6365e691ff533f9809f5e69ae08ffa6740e93 100644 (file)
@@ -81,7 +81,9 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal
     protected Iterable<IAnalysisProgressListener> getListeners() {
         List<IAnalysisProgressListener> listeners = new ArrayList<>();
         for (Object listener : fListeners.getListeners()) {
-            listeners.add((IAnalysisProgressListener) listener);
+            if (listener != null) {
+                listeners.add((IAnalysisProgressListener) listener);
+            }
         }
         return listeners;
     }
index 5ffc52f96ec641846f5fe6ecb56babae6341fac3..f14f2579ffac6b4ce9e494c04fac786f5320bf44 100644 (file)
 
 package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNullContents;
+
 import java.util.Arrays;
 import java.util.Comparator;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
@@ -51,7 +54,7 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider
     @Override
     public void updateElement(int index) {
         final TableViewer tableViewer = fTableViewer;
-        final ISegment[] segmentArray = fSegmentArray;
+        final ISegment @Nullable [] segmentArray = fSegmentArray;
         if (tableViewer != null && segmentArray != null) {
             tableViewer.replace(segmentArray[index], index);
         }
@@ -68,16 +71,24 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider
     public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) {
         fTableViewer = (TableViewer) viewer;
         if (newInput instanceof ISegmentStore) {
+            @SuppressWarnings("unchecked")
             ISegmentStore<ISegment> segmentStore = (ISegmentStore<ISegment>) newInput;
-            fSegmentArray = Iterables.toArray(segmentStore, ISegment.class);
+            ISegment[] array = Iterables.toArray(segmentStore, ISegment.class);
+            @NonNull ISegment[] checkedArray = checkNotNullContents(array);
             if (fComparator != null) {
-                Arrays.sort(fSegmentArray, fComparator);
+                Arrays.sort(checkedArray, fComparator);
             }
+            fSegmentArray = checkedArray;
         } else if (newInput instanceof ISegment[]) {
-            fSegmentArray = ((ISegment[]) newInput).clone();
+            /*
+             * Ensure that there are no null elements in the array, so we can
+             * set it back to fSegmentArray, which does not allow nulls.
+             */
+            @NonNull ISegment[] checkedArray = checkNotNullContents((@Nullable ISegment[]) newInput);
             if (fComparator != null) {
-                Arrays.sort(fSegmentArray, fComparator);
+                Arrays.sort(checkedArray, fComparator);
             }
+            fSegmentArray = checkedArray;
         } else {
             fSegmentArray = null;
         }
@@ -85,18 +96,21 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider
 
     @Override
     public void setSortOrder(@Nullable Comparator<?> comparator) {
+        @NonNull ISegment @Nullable [] segmentArray = fSegmentArray;
         if (comparator == null) {
             return;
         }
-        if (fSegmentArray == null) {
+        if (segmentArray == null) {
             return;
         }
         final TableViewer tableViewer = fTableViewer;
         if (tableViewer == null) {
             return;
         }
-        fComparator = (Comparator<ISegment>) comparator;
-        Arrays.sort(fSegmentArray, fComparator);
+        @SuppressWarnings("unchecked")
+        Comparator<ISegment> comp = (Comparator<ISegment>) comparator;
+        fComparator = comp;
+        Arrays.sort(segmentArray, fComparator);
         tableViewer.refresh();
     }
 
index 835c280ff30f670129dfe05e1e29b108142a4973..aa5c23bf776404e9f5ec843e4fe6d6cade88a7f0 100644 (file)
@@ -44,7 +44,7 @@ public class BtfEventType extends TmfEventType {
             BtfColumnNames.NOTES.toString() };
     private static final @NonNull ITmfEventField FIELDS_WITHOUT_NOTES = TmfEventField.makeRoot(FIELD_WITH_NOTES_COLUMNS);
     private static final @NonNull ITmfEventField FIELDS_WITH_NOTES = TmfEventField.makeRoot(FIELDS_WITHOUT_NOTES_COLUMNS);
-    private final String fName;
+    private final @NonNull String fName;
     private final String fDescription;
     private final boolean fHasNotes;
     private final List<String> fCols;
@@ -55,7 +55,7 @@ public class BtfEventType extends TmfEventType {
      * @param name the event name
      * @param description the event description
      */
-    public BtfEventType(String name, String description) {
+    public BtfEventType(@NonNull String name, String description) {
         super();
         fName = name;
         fDescription = description;
index 9570cc17d741db9da7046985c2f67b7553346d3b..0b0364e131e7d82de970a2e7b5ff22afac72adc7 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.btf.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
+
 import java.util.Map;
 
 import org.eclipse.tracecompass.btf.core.Messages;
@@ -33,22 +35,22 @@ public final class BtfEventTypeFactory {
     static {
         ImmutableMap.Builder<String, BtfEventType> builder = new ImmutableMap.Builder<>();
         // Environment
-        builder.put("STI", new BtfEventType(Messages.BtfTypeId_STIName, Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$
+        builder.put("STI", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_STIName), Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$
         // Software
-        builder.put("T", new BtfEventType(Messages.BtfTypeId_TName, Messages.BtfTypeId_TDescr)); //$NON-NLS-1$
-        builder.put("ISR", new BtfEventType(Messages.BtfTypeId_ISRName, Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$
-        builder.put("R", new BtfEventType(Messages.BtfTypeId_RName, Messages.BtfTypeId_RDescr)); //$NON-NLS-1$
-        builder.put("IB", new BtfEventType(Messages.BtfTypeId_IBName, Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$
+        builder.put("T", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_TName), Messages.BtfTypeId_TDescr)); //$NON-NLS-1$
+        builder.put("ISR", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ISRName), Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$
+        builder.put("R", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_RName), Messages.BtfTypeId_RDescr)); //$NON-NLS-1$
+        builder.put("IB", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_IBName), Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$
         // Hardware
-        builder.put("ECU", new BtfEventType(Messages.BtfTypeId_ECUName, Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$
-        builder.put("P", new BtfEventType(Messages.BtfTypeId_PName, Messages.BtfTypeId_PDescr)); //$NON-NLS-1$
-        builder.put("C", new BtfEventType(Messages.BtfTypeId_CName, Messages.BtfTypeId_CDescr)); //$NON-NLS-1$
+        builder.put("ECU", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ECUName), Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$
+        builder.put("P", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_PName), Messages.BtfTypeId_PDescr)); //$NON-NLS-1$
+        builder.put("C", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_CName), Messages.BtfTypeId_CDescr)); //$NON-NLS-1$
         // Operating system
-        builder.put("SCHED", new BtfEventType(Messages.BtfTypeId_SCHEDName, Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$
-        builder.put("SIG", new BtfEventType(Messages.BtfTypeId_SIGName, Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$
-        builder.put("SEM", new BtfEventType(Messages.BtfTypeId_SEMName, Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$
+        builder.put("SCHED", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SCHEDName), Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$
+        builder.put("SIG", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIGName), Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$
+        builder.put("SEM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SEMName), Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$
         // Information
-        builder.put("SIM", new BtfEventType(Messages.BtfTypeId_SIMName, Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$
+        builder.put("SIM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIMName), Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$
         TYPES = builder.build();
     }
 
index af7845b7c7533381dbf485a075c1cdb5a2d7822b..5daaa96c47b6389ca2aece4baa0b0fca2f11b812 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.eclipse.tracecompass.common.core.collect;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.function.Function;
 import java.util.stream.Stream;
 
@@ -47,8 +49,9 @@ public class StreamFlattener<T> {
      *         recursively.
      */
     public Stream<T> flatten(T element) {
-        return Stream.concat(
+        Stream<T> ret = Stream.concat(
                 Stream.of(element),
                 fGetChildrenFunction.apply(element).flatMap(this::flatten));
+        return checkNotNull(ret);
     }
 }
index bb2392fc086d7c8276149cb8169de3cf1e087066..166b8e1da5208afbceb61ae165048e79a9bac7eb 100644 (file)
@@ -98,7 +98,7 @@ public interface IEventDeclaration {
      *
      * @return The set of custom attributes
      */
-    Set<String> getCustomAttributes();
+    @NonNull Set<@NonNull String> getCustomAttributes();
 
     /**
      * Get the value of a given CTF attribute.
index ffa0b8bf84822bf081c3265cd8252b2f94d2bbdb..77238602f31d0a3e347429125aec9f20ebcaa489 100644 (file)
@@ -353,8 +353,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         }
         sb.append("type:").append(fContainerType.toString()); //$NON-NLS-1$
         sb.append(']');
-        String string = sb.toString();
-        return string;
+        return sb.toString();
     }
 
     @Override
index c6ec4053a16cbc3ba4f3bbe9a8536939c8d17510..c614d00e4ecc123def5d8a5d1d889091d6cbcfad 100644 (file)
@@ -46,7 +46,7 @@ public final class StructDefinition extends ScopedDefinition implements IComposi
     // Attributes
     // ------------------------------------------------------------------------
 
-    private final ImmutableList<String> fFieldNames;
+    private final @NonNull List<String> fFieldNames;
     private final Definition[] fDefinitions;
     private Map<String, Definition> fDefinitionsMap = null;
 
@@ -128,7 +128,7 @@ public final class StructDefinition extends ScopedDefinition implements IComposi
     }
 
     @Override
-    public List<String> getFieldNames() {
+    public @NonNull List<String> getFieldNames() {
         return fFieldNames;
     }
 
@@ -152,15 +152,13 @@ public final class StructDefinition extends ScopedDefinition implements IComposi
 
         builder.append("{ "); //$NON-NLS-1$
 
-        if (fFieldNames != null) {
-            List<String> fields = new LinkedList<>();
-            for (String field : fFieldNames) {
-                String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$
-                fields.add(appendee);
-            }
-            Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
-            builder.append(joiner.join(fields));
+        List<String> fields = new LinkedList<>();
+        for (String field : fFieldNames) {
+            String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$
+            fields.add(appendee);
         }
+        Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
+        builder.append(joiner.join(fields));
 
         builder.append(" }"); //$NON-NLS-1$
 
index f8355b97dd3078e7abb32a6cd43e089313a129e2..1a871ddbb1a8a99af9cf8f2fefab92259c9ed839 100644 (file)
@@ -16,6 +16,7 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import java.util.Collection;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.CTFException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
@@ -128,13 +129,13 @@ public class SequenceDeclaration extends CompoundDeclaration {
             fPaths.put(fieldName, fieldName + '[' + collection.size() + ']');
         }
         List<String> paths = (List<String>) fPaths.get(fieldName);
-        Builder<Definition> definitions = new ImmutableList.Builder<>();
+        Builder<@NonNull Definition> definitions = new ImmutableList.Builder<>();
         for (int i = 0; i < length; i++) {
             /* We should not have inserted any null values */
             String elemName = checkNotNull(paths.get(i));
             definitions.add(fElemType.createDefinition(definitionScope, elemName, input));
         }
-        List<Definition> list = checkNotNull(definitions.build());
+        List<@NonNull Definition> list = checkNotNull(definitions.build());
         return new ArrayDefinition(this, definitionScope, fieldName, list);
     }
 
index 0ca7d58199a28c98ba3b5f21ccf00cd04836f1ea..f98ad6682ac99be21a479581c4bfaa7ed75bbf9d 100644 (file)
@@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableList;
  */
 public final class EventHeaderDefinition extends Definition implements ICompositeDefinition {
 
-    private static final List<String> FIELD_NAMES = ImmutableList.of(
+    private static final @NonNull List<String> FIELD_NAMES = ImmutableList.of(
             IEventHeaderDeclaration.ID,
             IEventHeaderDeclaration.TIMESTAMP
             );
@@ -99,7 +99,7 @@ public final class EventHeaderDefinition extends Definition implements IComposit
     }
 
     @Override
-    public List<String> getFieldNames() {
+    public @NonNull List<String> getFieldNames() {
         return FIELD_NAMES;
     }
 }
\ No newline at end of file
index e7f56bda48611b0cb3ab4410dcf927d1d624f46e..16b6586013c50d987c0514463f426ae2ad273e7b 100644 (file)
@@ -413,7 +413,7 @@ public class CtfTmfTraceTest {
      */
     @Test
     public void testEventLookup() {
-        Set<? extends ITmfEventType> eventTypes = fixture.getContainedEventTypes();
+        Set<@NonNull ? extends ITmfEventType> eventTypes = fixture.getContainedEventTypes();
         Set<String> eventNames = TmfEventTypeCollectionHelper.getEventNames(eventTypes);
         assertTrue(eventNames.contains("sched_switch"));
         assertFalse(eventNames.contains("Sched_switch"));
index e6c1ae15e94453de8925c4c8482225e8b1e630b4..299ad2e5aed353c4c13e2a1ff018649e8784506a 100644 (file)
@@ -16,6 +16,7 @@ package org.eclipse.tracecompass.internal.tmf.ctf.core.trace.iterator;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.equalsNullable;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.CTFException;
 import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
 import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
@@ -43,7 +44,7 @@ public class CtfIterator extends CTFTraceReader
     /** An invalid location */
     public static final CtfLocation NULL_LOCATION = new CtfLocation(CtfLocation.INVALID_LOCATION);
 
-    private final CtfTmfTrace fTrace;
+    private final @NonNull CtfTmfTrace fTrace;
 
     private CtfLocation fCurLocation;
     private long fCurRank;
@@ -69,7 +70,7 @@ public class CtfIterator extends CTFTraceReader
      *             If the iterator couldn't not be instantiated, probably due to
      *             a read error.
      */
-    public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace) throws CTFException {
+    public CtfIterator(CTFTrace ctfTrace, @NonNull CtfTmfTrace ctfTmfTrace) throws CTFException {
         super(ctfTrace);
         fTrace = ctfTmfTrace;
         if (hasMoreEvents()) {
@@ -97,7 +98,7 @@ public class CtfIterator extends CTFTraceReader
      *             If the iterator couldn't not be instantiated, probably due to
      *             a read error.
      */
-    public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank)
+    public CtfIterator(CTFTrace ctfTrace, @NonNull CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank)
             throws CTFException {
         super(ctfTrace);
 
@@ -330,8 +331,7 @@ public class CtfIterator extends CTFTraceReader
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = (prime * result)
-                + ((fTrace == null) ? 0 : fTrace.hashCode());
+        result = (prime * result) + fTrace.hashCode();
         result = (prime * result)
                 + ((fCurLocation == null) ? 0 : fCurLocation.hashCode());
         result = (prime * result) + (int) (fCurRank ^ (fCurRank >>> 32));
index 17ef0213ca92be4330b977a38dc093744b243390..6c1688300d862047bb8960f7e36be34bbc973bfd 100644 (file)
@@ -293,7 +293,7 @@ public class CtfTmfEvent extends TmfEvent
         if (declaration == null) {
             return new HashSet<>();
         }
-        return checkNotNull(declaration.getCustomAttributes());
+        return declaration.getCustomAttributes();
     }
 
     @Override
index 6bc6d92e10581e6035dc6f4293d88a1e574299c6..b891bc1da21799a821d96fb88f059dd62e327f5a 100644 (file)
@@ -101,7 +101,7 @@ public abstract class CtfTmfEventField extends TmfEventField {
      *            String The name to assign to this field
      * @return The resulting CtfTmfEventField object
      */
-    public static CtfTmfEventField parseField(IDefinition fieldDef,
+    public static @NonNull CtfTmfEventField parseField(IDefinition fieldDef,
             @NonNull String fieldName) {
         CtfTmfEventField field = null;
 
index 10340dca6ad194416a719994d105855293bdee1b..39db1877b9cca095d3ef6fbf289a9af47756dea6 100644 (file)
@@ -11,6 +11,7 @@
 
 package org.eclipse.tracecompass.tmf.ctf.core.event;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
 
@@ -29,7 +30,7 @@ public class CtfTmfEventType extends TmfEventType {
      * @param content
      *            The event field
      */
-    public CtfTmfEventType(String eventName, ITmfEventField content) {
+    public CtfTmfEventType(@NonNull String eventName, ITmfEventField content) {
         super(eventName, content);
     }
 
index 4bc464bc27150468d8e53a08497bd51c22d4f059..878da4a2e2ce39d9fa30c07581b1120303ab1b35 100644 (file)
@@ -213,7 +213,7 @@ public class CtfTmfTrace extends TmfTrace
                                     null,
                                     content.toArray(new ITmfEventField[content.size()]));
 
-                            ctfTmfEventType = new CtfTmfEventType(ied.getName(), contentTree);
+                            ctfTmfEventType = new CtfTmfEventType(checkNotNull(ied.getName()), contentTree);
                             fContainedEventTypes.put(ctfTmfEventType.getName(), ctfTmfEventType);
                         }
                     }
index ffd8e119a85bdc1f212c48a98f49278378dc7ffd..55c2dce1525f5d046ed284d22f0522fe4ae34b9c 100644 (file)
@@ -30,6 +30,7 @@ import java.util.regex.Pattern;
 
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells.TestCommandShell;
 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandOutputListener;
@@ -201,8 +202,8 @@ public class LTTngToolsFileShell extends TestCommandShell {
                             // Save output/result in command map
                             if (output != null && errorOutput != null) {
                                 commandMap.put(input, createCommandResult(result,
-                                        checkNotNull(output.toArray(new String[output.size()])),
-                                        checkNotNull(errorOutput.toArray(new String[errorOutput.size()]))));
+                                        checkNotNull(output.toArray(new @NonNull String[output.size()])),
+                                        checkNotNull(errorOutput.toArray(new @NonNull String[errorOutput.size()]))));
                             }
                             inOutput = false;
                         } else if (OUTPUT_KEY.equals(strLine)) {
@@ -273,7 +274,7 @@ public class LTTngToolsFileShell extends TestCommandShell {
             return checkNotNull(commands.get(fullCommand));
         }
 
-        String[] output = new String[1];
+        @NonNull String[] output = new @NonNull String[1];
         output[0] = String.valueOf("Command not found");
         ICommandResult result = createCommandResult(1, output, output);
         return result;
index a44f6f2088a5fd36ea721a4d13c97d1cb99f20cb..45ee3264bc55ede79fd3b3c001d0f187a68eb871 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
@@ -137,7 +138,7 @@ public class AssignEventHandler extends BaseControlViewHandler {
 
     @Override
     public boolean isEnabled() {
-        ArrayList<BaseEventComponent> events = new ArrayList<>();
+        @NonNull ArrayList<@NonNull BaseEventComponent> events = new ArrayList<>();
         TraceSessionComponent[] sessions = null;
         Boolean isKernel = null;
 
index fa7346dfba7c00a633db7df2439ea65a3e789d16..595e3d92e1b60b977a452c0495349310059ab8f6 100644 (file)
@@ -50,7 +50,7 @@ class NullControlService implements ILttngControlService {
 
     @Override
     public List<String> getSessionNames(IProgressMonitor monitor) throws ExecutionException {
-        return checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
     @Override
@@ -65,17 +65,17 @@ class NullControlService implements ILttngControlService {
 
     @Override
     public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException {
-        return checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
     @Override
     public List<IUstProviderInfo> getUstProvider() throws ExecutionException {
-        return checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
     @Override
     public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException {
-        return checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
     @Override
@@ -125,7 +125,7 @@ class NullControlService implements ILttngControlService {
 
     @Override
     public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException {
-        return checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
     @Override
index 9d88d223f1f86bb09f16376e1cf3d228c838ca2b..ab9691dce38fe3b3807f096bfde87174f3f511ec 100644 (file)
  **********************************************************************/
 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.logging.ControlCommandLogger;
 
@@ -144,8 +147,8 @@ public class ControlPreferences {
     /**
      * @return value of tracing group preference
      */
-    public String getTracingGroup() {
-        return fPreferenceStore.getString(TRACE_CONTROL_TRACING_GROUP_PREF);
+    public @NonNull String getTracingGroup() {
+        return checkNotNull(fPreferenceStore.getString(TRACE_CONTROL_TRACING_GROUP_PREF));
     }
 
     /**
index e531a4a21dd4d373ec4497c575bde16f26d25ef8..e7e6f456675a51959e30f4d0fc5c99e887874ed1 100644 (file)
@@ -1067,7 +1067,7 @@ public class LTTngControlService implements ILttngControlService {
             }
             String[] args = commandLine.split("\\s+"); //$NON-NLS-1$
             ICommandInput command = fCommandShell.createCommand();
-            command.addAll(checkNotNull(Arrays.asList(args)));
+            command.addAll(Arrays.asList(args));
             ICommandResult result = executeCommand(command, monitor);
 
             if (isError(result)) {
@@ -1474,7 +1474,7 @@ public class LTTngControlService implements ILttngControlService {
     protected @NonNull ICommandInput createCommand(String... segments) {
         ICommandInput command = fCommandShell.createCommand();
         command.add(LTTngControlServiceConstants.CONTROL_COMMAND);
-        List<String> groupOption = getTracingGroupOption();
+        List<@NonNull String> groupOption = getTracingGroupOption();
         if (!groupOption.isEmpty()) {
             command.addAll(groupOption);
         }
@@ -1491,8 +1491,8 @@ public class LTTngControlService implements ILttngControlService {
     /**
      * @return the tracing group option if configured in the preferences
      */
-    protected @NonNull List<String> getTracingGroupOption() {
-        List<String> groupOption = new ArrayList<>();
+    protected @NonNull List<@NonNull String> getTracingGroupOption() {
+        List<@NonNull String> groupOption = new ArrayList<>();
         if (!ControlPreferences.getInstance().isDefaultTracingGroup() && !ControlPreferences.getInstance().getTracingGroup().equals("")) { //$NON-NLS-1$
             groupOption.add(LTTngControlServiceConstants.OPTION_TRACING_GROUP);
             groupOption.add(ControlPreferences.getInstance().getTracingGroup());
index 0b1c77fe7c7a93bd6323c74aaec910c7eb934801..cdf9c4bb8de857c1bf8f1be8a9917e5332f7cd04 100644 (file)
@@ -740,7 +740,7 @@ public class LTTngControlServiceMI extends LTTngControlService {
     protected ICommandInput createCommand(String... strings) {
         ICommandInput command = getCommandShell().createCommand();
         command.add(LTTngControlServiceConstants.CONTROL_COMMAND);
-        List<String> groupOption = getTracingGroupOption();
+        List<@NonNull String> groupOption = getTracingGroupOption();
         if (!groupOption.isEmpty()) {
             command.addAll(groupOption);
         }
index ddce8fe44f2c896822c094422c502c274c59794a..6c2a0c7eae23d8bb7f306257715cc1161f323e33 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.event.matching;
 
 import java.util.Set;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.test.performance.Dimension;
 import org.eclipse.test.performance.Performance;
 import org.eclipse.test.performance.PerformanceMeter;
@@ -58,7 +59,7 @@ public class EventMatchingBenchmark {
         CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
         CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
 
-        Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2);
+        Set<@NonNull ITmfTrace> traces = ImmutableSet.of(trace1, trace2);
         runCpuTest(traces, "Match TCP events", 100);
 
         trace1.dispose();
@@ -75,7 +76,7 @@ public class EventMatchingBenchmark {
         CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_DB);
         CtfTmfTrace trace3 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_HTTPD);
 
-        Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2, trace3);
+        Set<@NonNull ITmfTrace> traces = ImmutableSet.of(trace1, trace2, trace3);
         runCpuTest(traces, "Django traces", 10);
         runMemoryTest(traces, "Django traces", 10);
 
@@ -84,7 +85,7 @@ public class EventMatchingBenchmark {
         trace3.dispose();
     }
 
-    private static void runCpuTest(Set<ITmfTrace> testTraces, String testName, int loop_count) {
+    private static void runCpuTest(Set<@NonNull ITmfTrace> testTraces, String testName, int loop_count) {
         Performance perf = Performance.getDefault();
         PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME);
         perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME);
@@ -101,7 +102,7 @@ public class EventMatchingBenchmark {
     }
 
     /* Benchmark memory used by the algorithm */
-    private static void runMemoryTest(Set<ITmfTrace> testTraces, String testName, int loop_count) {
+    private static void runMemoryTest(Set<@NonNull ITmfTrace> testTraces, String testName, int loop_count) {
         Performance perf = Performance.getDefault();
         PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY);
         perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP);
index a71beafcffdc95fd2d2d41d1fae7f348abb952ee..5580ee549bd0535d6e4af3e3bacd5721aef3f4c2 100644 (file)
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.Collections;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.test.performance.Dimension;
 import org.eclipse.test.performance.Performance;
 import org.eclipse.test.performance.PerformanceMeter;
@@ -89,14 +90,14 @@ public class TraceSynchronizationBenchmark {
         trace3.dispose();
     }
 
-    private static void runCpuTest(TmfExperiment experiment, String testName, int loop_count) {
+    private static void runCpuTest(@NonNull TmfExperiment experiment, String testName, int loop_count) {
         Performance perf = Performance.getDefault();
         PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME);
         perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME);
 
         for (int i = 0; i < loop_count; i++) {
             pm.start();
-            SynchronizationManager.synchronizeTraces(null, Collections.<ITmfTrace> singleton(experiment), true);
+            SynchronizationManager.synchronizeTraces(null, Collections.singleton(experiment), true);
             pm.stop();
         }
         pm.commit();
@@ -104,7 +105,7 @@ public class TraceSynchronizationBenchmark {
     }
 
     /* Benchmark memory used by the algorithm */
-    private static void runMemoryTest(TmfExperiment experiment, String testName, int loop_count) {
+    private static void runMemoryTest(@NonNull TmfExperiment experiment, String testName, int loop_count) {
         Performance perf = Performance.getDefault();
         PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY);
         perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP);
@@ -113,7 +114,7 @@ public class TraceSynchronizationBenchmark {
 
             System.gc();
             pm.start();
-            SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Collections.<ITmfTrace> singleton(experiment), true);
+            SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Collections.singleton(experiment), true);
             assertNotNull(algo);
 
             System.gc();
index 8fe186971cf5629f098a52dd254499677f4027ff..e9ffc3357b078c2a7c2c6c47825b021b42113cce 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.util.HashSet;
 import java.util.Set;
@@ -59,12 +61,14 @@ public enum VmTestExperiment {
      *         experiment
      */
     public synchronized TmfExperiment getExperiment(boolean deleteSuppFiles) {
-        Set<ITmfTrace> traces = new HashSet<>();
+        Set<@NonNull ITmfTrace> traces = new HashSet<>();
         for (VmTraces trace : fTraces) {
-            traces.add(trace.getTrace());
+            ITmfTrace tmfTrace = trace.getTrace();
+            if (tmfTrace != null) {
+                traces.add(tmfTrace);
+            }
         }
-        @SuppressWarnings("null")
-        @NonNull String expName = this.name();
+        String expName = checkNotNull(this.name());
         VirtualMachineExperiment experiment = new VirtualMachineExperiment(expName, traces);
         if (deleteSuppFiles) {
             /*
index e464161b2da950d4e4997766ff5d3e3caf95346f..d44ce16f901cd3908f285f4d97c8bfeb704bcbc6 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.lttng2.kernel.core.tests.Activator;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
@@ -69,7 +70,7 @@ public enum VmTraces {
      *
      * @return A TmfXmlTraceStub reference to this trace
      */
-    public ITmfTrace getTrace() {
+    public @Nullable ITmfTrace getTrace() {
         ITmfTrace trace = new TmfXmlTraceStub();
         IStatus status = trace.validate(null, fPath.toOSString());
         if (!status.isOK()) {
index 3b3b0c658876c6d682800e3f762ad54a5ce95002..0d82b95e2a7f844cbd960e671f2f78510dacede8 100644 (file)
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
 import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
@@ -47,7 +48,7 @@ public class MatchAndSyncTest {
         CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
         CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
 
-        List<ITmfTrace> tracearr = new LinkedList<>();
+        List<@NonNull ITmfTrace> tracearr = new LinkedList<>();
         tracearr.add(trace1);
         tracearr.add(trace2);
 
index 226aa200d6dcf314b7b74a23b088788de075bcf9..c6c66ba2ddd495c032e2fc10cd897fb42955398c 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
+
 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider;
@@ -46,7 +48,7 @@ public class TraceEventHandlerStatedump extends BaseHandler {
         }
 
         Integer tid = EventField.getInt(event, eventLayout.fieldTid());
-        String name = EventField.getOrDefault(event, eventLayout.fieldName(), Messages.TraceEventHandlerSched_UnknownThreadName);
+        String name = EventField.getOrDefault(event, eventLayout.fieldName(), nullToEmptyString(Messages.TraceEventHandlerSched_UnknownThreadName));
         Integer status = EventField.getInt(event, eventLayout.fieldStatus());
 
         String host = event.getTrace().getHostId();
index 4eef98ceafafb2af5c223a75b714a39b64e840d4..8fb8baacaa3b9fd162a093c6df1e6e49dc768a0a 100644 (file)
@@ -13,8 +13,6 @@
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.trace;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.util.Collections;
 import java.util.Set;
 
@@ -34,7 +32,7 @@ public class VirtualMachineExperiment extends TmfExperiment {
      * Default constructor. Needed by the extension point.
      */
     public VirtualMachineExperiment() {
-        this("", checkNotNull(Collections.EMPTY_SET)); //$NON-NLS-1$
+        this("", Collections.EMPTY_SET); //$NON-NLS-1$
     }
 
     /**
index 49d312ac06d53ac30f5064ca35a6c56364a27013..9ef8441220cf2ed19f44d3b75a538d8b30719436 100644 (file)
@@ -207,7 +207,7 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider {
          * Add this library to the pending entries, the matching
          * build_id/debug_link event will finish updating this attribute
          */
-        fPendingEntries.put(baddr, sopath);
+        fPendingEntries.put(baddr, checkNotNull(sopath));
     }
 
     /**
index 0692772894935602a1c5b5bb8c2144ab06925b91..82f87e56b5bee4e92915cb51f91a36ad907b68fe 100644 (file)
@@ -14,6 +14,7 @@
 package org.eclipse.tracecompass.lttng2.ust.core.analysis.memory;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
 
 import java.util.Set;
 
@@ -100,8 +101,8 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
          * In order to have these events, the libc wrapper with probes should be
          * loaded
          */
-        eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation);
-        eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation);
+        eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingInformation));
+        eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation));
 
         /* The domain type of the analysis */
         TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
index 595f464ad31d33e6cc2309d80e683a71c4efd013..574b0112796c70eebbc9c8232d5d43dc24934cd5 100644 (file)
@@ -19,6 +19,7 @@ import java.nio.ByteOrder;
 import java.util.Arrays;
 import java.util.Map;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
@@ -425,7 +426,7 @@ public class TCPPacket extends Packet {
     public Map<String, String> getFields() {
         Map<String, String> map = fFields;
         if (map == null) {
-            Builder<String, String> builder = ImmutableMap.<String, String> builder()
+            Builder<String, String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder()
                     .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$
                     .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$
                     .put("Sequence Number", String.valueOf(fSequenceNumber)) //$NON-NLS-1$
index 1abbf0a166122c830add5d4db33ffd37691389eb..169c2f51d3a7f93adb765f8bf18f678312481cbd 100644 (file)
@@ -16,6 +16,7 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.util.Map;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
@@ -205,7 +206,7 @@ public class UDPPacket extends Packet {
     public Map<String, String> getFields() {
         Map<String, String> map = fFields;
         if (map == null) {
-            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder()
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder()
                     .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$
                     .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$
                     .put("Length", String.valueOf(fTotalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
index 54a7c1cca6e8709d81d434954e5cc5247f515282..c214995b416236441a1699cd74afac3c2eb3d06a 100644 (file)
@@ -18,6 +18,7 @@ import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.util.Map;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
@@ -134,7 +135,7 @@ public class UnknownPacket extends Packet {
         if (map == null) {
             byte[] array = checkNotNull(fPayload.array());
 
-            Builder<String, String> builder = ImmutableMap.<String, String> builder()
+            Builder<String, String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder()
                     .put("Binary", ConversionHelper.bytesToHex(array, true)); //$NON-NLS-1$
             try {
                 String s = new String(array, "UTF-8"); //$NON-NLS-1$
index 269932328b61f43e0561d71465c9692b8c5939c8..6f9661a176a7147f9b12731798977ec9e27c760d 100644 (file)
@@ -210,21 +210,15 @@ public class PcapEventFieldTest {
     }
 
     // Convenience method
-    private static ITmfEventField[] generatePacketFields(Packet packet) {
+    private static ITmfEventField @NonNull [] generatePacketFields(Packet packet) {
         List<ITmfEventField> fieldList = new ArrayList<>();
         List<ITmfEventField> subfieldList = new ArrayList<>();
         Packet localPacket = packet;
 
         while (localPacket != null) {
             subfieldList.clear();
-            for (Map.Entry<String, String> entry : localPacket.getFields().entrySet()) {
-
-                @SuppressWarnings("null")
-                @NonNull
+            for (Map.Entry<@NonNull String, @NonNull String> entry : localPacket.getFields().entrySet()) {
                 String key = entry.getKey();
-
-                @SuppressWarnings("null")
-                @NonNull
                 String value = entry.getValue();
                 subfieldList.add(new TmfEventField(key, value, null));
             }
index 8e9c1fc16f2e4e30b3c980bfb40f2300869ff584..33d84f43ba3246afe6f3dd329b35bf843b7a09d8 100644 (file)
@@ -210,7 +210,7 @@ public class PcapEvent extends TmfEvent {
         }
 
         if (packet == null) {
-            fProtocols = checkNotNull(Collections.EMPTY_LIST);
+            fProtocols = Collections.EMPTY_LIST;
             return fProtocols;
         }
         // Go through all the packets and add them to list.
index daa3fadc4904ae65b4b9af1b40d9da6ed98aa715..0cc4a2fbddf4bc5c3da5b05fc85fc7ac7934c6b3 100644 (file)
@@ -12,7 +12,6 @@
 
 package org.eclipse.tracecompass.internal.tmf.pcap.core.event;
 
-import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
@@ -41,7 +40,7 @@ public class PcapEventField extends TmfEventField {
      * @throws IllegalArgumentException
      *             If 'name' is null, or if 'fields' has duplicate field names.
      */
-    public PcapEventField(String name, Object value, @Nullable ITmfEventField[] fields, Packet packet) {
+    public PcapEventField(String name, Object value, ITmfEventField[] fields, Packet packet) {
         super(name, value, fields);
         fSummaryString = packet.getLocalSummaryString();
     }
index 795a70d7e135a16de599ac2c11efeb4541915c0b..5afcd8c22660d4995937c209bc75a84aa5e6ccb5 100644 (file)
@@ -40,7 +40,7 @@ public class PcapRootEventField extends TmfEventField {
      * @throws IllegalArgumentException
      *             If 'name' is null, or if 'fields' has duplicate field names.
      */
-    public PcapRootEventField(@Nullable ITmfEventField[] fields, Packet packet) {
+    public PcapRootEventField(ITmfEventField[] fields, Packet packet) {
         super(ITmfEventField.ROOT_FIELD_ID, null, fields);
         fPacketSourceField = new TmfEventField(PcapEvent.EVENT_FIELD_PACKET_SOURCE,
                 packet.getMostEcapsulatedPacket().getSourceEndpoint().toString(), null);
index c14f95c0c823bb23bfc8d8430fd78e135b4480d8..61b12b9997aaa4470c149798f49b356a706554d3 100644 (file)
@@ -26,9 +26,15 @@ public class BasicSegment implements ISegment {
 
     private static final long serialVersionUID = -3257452887960883177L;
 
-    private static final Comparator<ISegment> COMPARATOR = checkNotNull(Ordering
-            .from(SegmentComparators.INTERVAL_START_COMPARATOR)
-            .compound(SegmentComparators.INTERVAL_END_COMPARATOR));
+    private static final Comparator<ISegment> COMPARATOR;
+    static {
+        /* checkNotNull() has to be called separately, or else it breaks the
+         * type inference. */
+        Comparator<ISegment> comp = Ordering
+                .from(SegmentComparators.INTERVAL_START_COMPARATOR)
+                .compound(SegmentComparators.INTERVAL_END_COMPARATOR);
+        COMPARATOR = checkNotNull(comp);
+    }
 
     private final long fStart;
     private final long fEnd;
index f3e9b83dc2af729044ea9bc51f4da4f715365aff..7ac37cde945d77d8f35a20ebcbbcae1b0f1d7def 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.*;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
 import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFactory;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -96,7 +97,7 @@ public class InMemoryBackendTest {
      */
     @Test
     public void testDoQuery() {
-        List<ITmfStateInterval> interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
+        List<@Nullable ITmfStateInterval> interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
         for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
             interval.add(null);
         }
@@ -142,7 +143,7 @@ public class InMemoryBackendTest {
             testInterval(interval[8], 908, 998, 9);
             testInterval(interval[9], 909, 999, 9);
 
-            List<ITmfStateInterval> intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
+            List<@Nullable ITmfStateInterval> intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
             for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
                 intervalQuery.add(null);
             }
index f65b18df7ae1e1422aa93cf398b21d05e88065cd..73951589b829065e1388905565379679dc6bb559 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.tracecompass.statesystem.core.tests.statevalue;
 
 import static org.junit.Assert.assertTrue;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
@@ -24,6 +25,7 @@ import org.junit.Test;
  *
  * @author Naser Ezzati
  */
+@NonNullByDefault
 public class StateValueCompareToTest {
 
     // ------------------------------------------------------------------------
index 454e251a10e3c5288daf8b5c4efa0d8b9ba28260..5ec490c657f24d4571d6607563d2e9adcfb15bfc 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
 
 /**
  * State history back-end that stores its intervals in RAM only. It cannot be
@@ -231,7 +232,7 @@ public class InMemoryBackend implements IStateHistoryBackend {
     }
 
     private static Iterator<ITmfStateInterval> serachforEndTime(TreeSet<ITmfStateInterval> tree, long time) {
-        ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, null);
+        ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, TmfStateValue.nullValue());
         ITmfStateInterval myInterval = tree.lower(dummyInterval);
         if (myInterval == null) {
             return tree.iterator();
index 30e6eb809ebf158438d22d67c0eec96abe2294e0..dc5a31d9960afd025f51feaa10fe3afcfa5cab56 100644 (file)
@@ -18,6 +18,7 @@ package org.eclipse.tracecompass.internal.statesystem.core.backend.historytree;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
@@ -62,7 +63,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
     private final long start;
     private final long end;
     private final int attribute;
-    private final TmfStateValue sv;
+    private final @NonNull TmfStateValue sv;
 
     /*
      * Size of the strings section entry used by this interval (= 0 if not used)
@@ -85,7 +86,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
      *             If the start time or end time are invalid
      */
     public HTInterval(long intervalStart, long intervalEnd, int attribute,
-            TmfStateValue value) throws TimeRangeException {
+            @NonNull TmfStateValue value) throws TimeRangeException {
         if (intervalStart > intervalEnd) {
             throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$
         }
@@ -104,7 +105,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
      * {@link #computeStringsEntrySize()} and do an extra copy.
      */
     private HTInterval(long intervalStart, long intervalEnd, int attribute,
-            TmfStateValue value, int size) throws TimeRangeException {
+            @NonNull TmfStateValue value, int size) throws TimeRangeException {
         if (intervalStart > intervalEnd) {
             throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$
         }
index 08727c1afe97cba90570aed3711a7c591c067719..9013b897878a06fa58d20c3027cf2affc0c328f4 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
@@ -172,7 +173,7 @@ public abstract class HTNode {
      * @throws IOException
      *             If there was an error reading from the file channel
      */
-    public static final HTNode readNode(HTConfig config, FileChannel fc)
+    public static final @NonNull HTNode readNode(HTConfig config, FileChannel fc)
             throws IOException {
         HTNode newNode = null;
         int res, i;
index 11620b353b63e546d903d40380ccf7f7cd336bb9..65911113bf8d89e6c4912292bbae532065b6c959 100644 (file)
@@ -19,6 +19,7 @@ import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.FileChannel;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.statesystem.core.Activator;
 
 /**
@@ -99,7 +100,7 @@ class HT_IO {
      *             reading. Instead of using a big reader-writer lock, we'll
      *             just catch this exception.
      */
-    public synchronized HTNode readNode(int seqNumber) throws ClosedChannelException {
+    public synchronized @NonNull HTNode readNode(int seqNumber) throws ClosedChannelException {
         /* Do a cache lookup */
         int offset = seqNumber & (CACHE_SIZE - 1);
         HTNode readNode = fNodeCache[offset];
@@ -115,12 +116,13 @@ class HT_IO {
             /* Put the node in the cache. */
             fNodeCache[offset] = readNode;
             return readNode;
+
         } catch (ClosedChannelException e) {
             throw e;
         } catch (IOException e) {
             /* Other types of IOExceptions shouldn't happen at this point though */
             Activator.getDefault().logError(e.getMessage(), e);
-            return null;
+            throw new IllegalStateException();
         }
     }
 
index 32fbeb6e182026087b17d4a9dd2cf9802e055170..d8f25d4dedb4df83a76f979ef0d17657217bd4ee 100644 (file)
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.statesystem.core.Activator;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
@@ -73,7 +74,7 @@ public class HistoryTree {
     private int fNodeCount;
 
     /** "Cache" to keep the active nodes in memory */
-    private final List<HTNode> fLatestBranch;
+    private final List<@NonNull HTNode> fLatestBranch;
 
     // ------------------------------------------------------------------------
     // Constructors/"Destructors"
@@ -101,7 +102,7 @@ public class HistoryTree {
         fConfig = conf;
         fTreeEnd = conf.getTreeStart();
         fNodeCount = 0;
-        fLatestBranch = Collections.synchronizedList(new ArrayList<HTNode>());
+        fLatestBranch = Collections.synchronizedList(new ArrayList<>());
 
         /* Prepare the IO object */
         fTreeIO = new HT_IO(fConfig, true);
@@ -216,8 +217,8 @@ public class HistoryTree {
      *            start
      * @throws ClosedChannelException
      */
-    private List<HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
-        List<HTNode> list = new ArrayList<>();
+    private List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
+        List<@NonNull HTNode> list = new ArrayList<>();
 
         HTNode nextChildNode = fTreeIO.readNode(rootNodeSeqNb);
         list.add(nextChildNode);
@@ -343,7 +344,7 @@ public class HistoryTree {
      *
      * @return The immutable latest branch
      */
-    protected List<HTNode> getLatestBranch() {
+    protected List<@NonNull HTNode> getLatestBranch() {
         return ImmutableList.copyOf(fLatestBranch);
     }
 
@@ -600,7 +601,7 @@ public class HistoryTree {
      *            Start time of the new node
      * @return The newly created node
      */
-    private CoreNode initNewCoreNode(int parentSeqNumber, long startTime) {
+    private @NonNull CoreNode initNewCoreNode(int parentSeqNumber, long startTime) {
         CoreNode newNode = new CoreNode(fConfig, fNodeCount, parentSeqNumber,
                 startTime);
         fNodeCount++;
@@ -621,7 +622,7 @@ public class HistoryTree {
      *            Start time of the new node
      * @return The newly created node
      */
-    private LeafNode initNewLeafNode(int parentSeqNumber, long startTime) {
+    private @NonNull LeafNode initNewLeafNode(int parentSeqNumber, long startTime) {
         LeafNode newNode = new LeafNode(fConfig, fNodeCount, parentSeqNumber,
                 startTime);
         fNodeCount++;
index d3cd7828c0496b99fe87fdae04abf4130dac5db1..093e781dc33f73159e001d61196ac67c97560d64 100644 (file)
@@ -18,6 +18,7 @@ import java.io.PrintWriter;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
@@ -79,7 +80,7 @@ public interface IStateHistoryBackend {
      */
     // FIXME change to IStateInterval?
     void insertPastState(long stateStartTime, long stateEndTime,
-            int quark, ITmfStateValue value) throws TimeRangeException;
+            int quark, @NonNull ITmfStateValue value) throws TimeRangeException;
 
     /**
      * Indicate to the provider that we are done building the history (so it can
@@ -159,7 +160,7 @@ public interface IStateHistoryBackend {
      * @throws StateSystemDisposedException
      *             If the state system is disposed while a request is ongoing.
      */
-    void doQuery(@NonNull List<ITmfStateInterval> currentStateInfo, long t)
+    void doQuery(@NonNull List<@Nullable ITmfStateInterval> currentStateInfo, long t)
             throws TimeRangeException, StateSystemDisposedException;
 
     /**
index d2bd91c4f33af72096141e713c44cef8a1032a87..81c6ce46a9267be53bb4cd49ea2d3518f55e183c 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.tracecompass.statesystem.core.interval;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 
 import com.google.common.base.Objects;
@@ -28,7 +29,7 @@ public final class TmfStateInterval implements ITmfStateInterval {
     private final long start;
     private final long end;
     private final int attribute;
-    private final ITmfStateValue sv;
+    private final @NonNull ITmfStateValue sv;
 
     /**
      * Construct an interval from its given parameters
@@ -43,7 +44,7 @@ public final class TmfStateInterval implements ITmfStateInterval {
      *            State value this interval will contain
      */
     public TmfStateInterval(long start, long end, int attribute,
-            ITmfStateValue sv) {
+            @NonNull ITmfStateValue sv) {
         this.start = start;
         this.end = end;
         this.attribute = attribute;
index 708569d56563cea416678e5913f766cb5dfa9598..cc0ad19df2aa4804b83584028948f2043d24417c 100644 (file)
@@ -12,8 +12,6 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.util.Collections;
 import java.util.List;
 
@@ -65,7 +63,7 @@ public class TmfXmlReadOnlyStateValue extends TmfXmlStateValue {
      */
     public TmfXmlReadOnlyStateValue(TmfXmlReadOnlyModelFactory modelFactory, Element node,
             IXmlStateSystemContainer container, String eventField) {
-        super(modelFactory, node, container, checkNotNull(Collections.EMPTY_LIST), eventField);
+        super(modelFactory, node, container, Collections.EMPTY_LIST, eventField);
     }
 
 }
index ad73371c8523c9edc60121bf2253462d94ccf48b..5dc864ad6403d061ab06b46f27779fea11a985ee 100644 (file)
@@ -44,13 +44,13 @@ import org.w3c.dom.NodeList;
 public class XmlStateProvider extends AbstractTmfStateProvider implements IXmlStateSystemContainer {
 
     private final IPath fFilePath;
-    @NonNull private final String fStateId;
+    private final @NonNull String fStateId;
 
     /** List of all Event Handlers */
     private final List<TmfXmlEventHandler> fEventHandlers = new ArrayList<>();
 
     /** List of all Locations */
-    private final Set<TmfXmlLocation> fLocations;
+    private final @NonNull Set<@NonNull TmfXmlLocation> fLocations;
 
     /** Map for defined values */
     private final Map<String, String> fDefinedValues = new HashMap<>();
@@ -90,7 +90,7 @@ public class XmlStateProvider extends AbstractTmfStateProvider implements IXmlSt
 
         /* parser for the locations */
         List<Element> childElements = XmlUtils.getChildElements(doc, TmfXmlStrings.LOCATION);
-        Set<TmfXmlLocation> locations = new HashSet<>();
+        Set<@NonNull TmfXmlLocation> locations = new HashSet<>();
         for (Element element : childElements) {
             if (element == null) {
                 continue;
index 32545bee156a9b42f51cf075e020250e82970de0..cf9d23eb48e8349391e765ac1051e5742f369ca5 100644 (file)
@@ -33,6 +33,7 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.ISafeRunnable;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.module.Messages;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils;
@@ -70,7 +71,7 @@ public class XmlAnalysisModuleSource implements IAnalysisModuleSource {
             .append("org.eclipse.linuxtools.tmf.analysis.xml.core") //$NON-NLS-1$
             .append("xml_files"); //$NON-NLS-1$
 
-    private static List<IAnalysisModuleHelper> fModules = null;
+    private static List<@NonNull IAnalysisModuleHelper> fModules = null;
 
     /**
      * Constructor. It adds the new module listener to the analysis manager.
@@ -81,12 +82,14 @@ public class XmlAnalysisModuleSource implements IAnalysisModuleSource {
 
     @Override
     public synchronized Iterable<IAnalysisModuleHelper> getAnalysisModules() {
-        if (fModules == null) {
-            fModules = new ArrayList<>();
+        List<@NonNull IAnalysisModuleHelper> modules = fModules;
+        if (modules == null) {
+            modules = new ArrayList<>();
+            fModules = modules;
             populateBuiltinModules();
             populateAnalysisModules();
         }
-        return fModules;
+        return modules;
     }
 
     private static void processFile(File xmlFile) {
index 1027ee4d6f341dd601c6630feaedec24d30c18df..c39fe80775f0ed035c2aaf824e330cd2fdf5691d 100644 (file)
@@ -254,7 +254,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
             return;
         }
 
-        Set<ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
+        Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
         if (analysisIds.isEmpty()) {
             /*
              * No analysis specified, take all state system analysis modules
index 5f7be2e40cffcffa79b48e8164658cc6d6f037d9..0838a58c2fc97d08d489d5a322b9a0c702f150ce 100644 (file)
@@ -17,6 +17,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
 
@@ -52,9 +53,9 @@ public class AnalysisRequirementTest {
     private static final String VALUE_F = "Test Value F";
 
     /* Requirement information strings */
-    private static final String INFO_A = "This is an information.";
-    private static final String INFO_B = "This is another information.";
-    private static final String INFO_C = "This is the last information.";
+    private static final @NonNull String INFO_A = "This is an information.";
+    private static final @NonNull String INFO_B = "This is another information.";
+    private static final @NonNull String INFO_C = "This is the last information.";
 
     /**
      * Test suite for the {@link TmfAnalysisRequirement#addInformation} and the
index a1245df779b03a38a6033e866b0ee05d0ff07878..b335b3f25d72f67eb67f04086d6f746dc04cfceb 100644 (file)
@@ -48,7 +48,7 @@ public class TmfEventTest {
 
     private final @NonNull ITmfTrace fTrace = STUB_TRACE.getTrace();
 
-    private final String fTypeId = "TestType";
+    private final @NonNull String fTypeId = "TestType";
     private final @NonNull String fLabel1 = "AString";
     private final @NonNull String fLabel2 = "AnInteger";
     private final String[] fLabels = new String[] { fLabel1, fLabel2 };
index 0ff7437760fb7c2946adf69812ef9959e8d3e2fa..5348c2b01b1bc5dc8f0ab357daff5380632497f6 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
@@ -32,7 +33,7 @@ import org.junit.Test;
  */
 public class TmfAsyncSequenceDiagramEventTest {
 
-    private final String fTypeId  = "Some type";
+    private final @NonNull String fTypeId  = "Some type";
     private final String fLabel0  = "label1";
     private final String fLabel1  = "label2";
     private final String[] fLabels  = new String[] { fLabel0, fLabel1 };
index b11fc5e4744433e177ee6b31ad047b49312ee29e..476c6cae83fd35784d07e598a6f7a5f588576f98 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
@@ -32,9 +33,9 @@ import org.junit.Test;
  */
 public class TmfSyncSequenceDiagramEventTest {
 
-    private final String fTypeId  = "Some type";
-    private final String fLabel0  = "label1";
-    private final String fLabel1  = "label2";
+    private final @NonNull String fTypeId  = "Some type";
+    private final @NonNull String fLabel0  = "label1";
+    private final @NonNull String fLabel1  = "label2";
     private final String[] fLabels  = new String[] { fLabel0, fLabel1 };
 
     private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
index b39bcfa78356427440abf9a255e7fa58dea5b1f6..50332b97fe4b6ccff0a6aaa36a7929205047a33d 100644 (file)
@@ -13,6 +13,7 @@
 
 package org.eclipse.tracecompass.tmf.tests.stubs.trace.text;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
 
 /**
@@ -21,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
 public class SyslogEventType extends TmfEventType {
 
     /** The event type id string. */
-    public static final String TYPE_ID = "Syslog"; //$NON-NLS-1$
+    public static final @NonNull String TYPE_ID = "Syslog"; //$NON-NLS-1$
 
     /** A default instance of this class */
     public static final SyslogEventType INSTANCE = new SyslogEventType();
index 81868854e434afce432e9ee7cff2404e0cb07e40..c1d1f57a65b4e26c971aeeb0ef918e88063d2359 100644 (file)
@@ -58,7 +58,9 @@ public final class TmfAnalysisModuleSources {
             if (elementName.equals(SOURCE_ELEM)) {
                 try {
                     IAnalysisModuleSource source = (IAnalysisModuleSource) ce.createExecutableExtension(CLASS_ATTR);
-                    sources.add(source);
+                    if (source != null) {
+                        sources.add(source);
+                    }
                 } catch (InvalidRegistryObjectException e) {
                     Activator.logError("Error creating module source", e); //$NON-NLS-1$
                 } catch (CoreException e) {
index 471bc71b1f9afde7ca3e8d0c395c5a4a7f54d8fc..e937676e405a4072b003a3c06fb9e463ac718b97 100644 (file)
@@ -13,6 +13,7 @@ package org.eclipse.tracecompass.internal.tmf.core.filter;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.collapse.ITmfCollapsibleEvent;
 import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode;
@@ -74,8 +75,8 @@ public class TmfCollapseFilter implements ITmfFilterTreeNode {
     }
 
     @Override
-    public ITmfFilterTreeNode[] getChildren() {
-        return new ITmfFilterTreeNode[0];
+    public @NonNull ITmfFilterTreeNode[] getChildren() {
+        return new @NonNull ITmfFilterTreeNode[0];
     }
 
     @Override
index e9b269c014fc61454fa57195c7e4af1b81664ee4..474226858aa181a0fd60f08166034fd355daffdc 100644 (file)
@@ -12,6 +12,9 @@
 
 package org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNullContents;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.PrintWriter;
@@ -19,8 +22,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.CountDownLatch;
+import java.util.stream.Collectors;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -204,7 +209,7 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
     }
 
     @Override
-    public void doQuery(List<ITmfStateInterval> currentStateInfo, long t)
+    public void doQuery(List<@Nullable ITmfStateInterval> currentStateInfo, long t)
             throws TimeRangeException, StateSystemDisposedException {
         /* Wait for required steps to be done */
         waitForCheckpoints();
@@ -222,8 +227,11 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
          * Set the initial contents of the partial state system (which is the
          * contents of the query at the checkpoint).
          */
+        List<@NonNull ITmfStateInterval> filledStateInfo =
+                checkNotNullContents(currentStateInfo.stream()).collect(Collectors.toList());
+
         fPartialSS.takeQueryLock();
-        fPartialSS.replaceOngoingState(currentStateInfo);
+        fPartialSS.replaceOngoingState(filledStateInfo);
 
         /* Send an event request to update the state system to the target time. */
         TmfTimeRange range = new TmfTimeRange(
@@ -251,11 +259,10 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
         try {
             for (int i = 0; i < currentStateInfo.size(); i++) {
                 long start = 0;
-                ITmfStateValue val = null;
                 start = ((ITmfStateSystem) fPartialSS).getOngoingStartTime(i);
-                val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i);
+                ITmfStateValue val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i);
 
-                ITmfStateInterval interval = new TmfStateInterval(start, t, i, val);
+                ITmfStateInterval interval = new TmfStateInterval(start, t, i, checkNotNull(val));
                 currentStateInfo.set(i, interval);
             }
         } catch (AttributeNotFoundException e) {
index 4ed606998b3e0ec4d2e246456288a24ab2e91d45..8756de2be38328adcfdd20d44b8639507a3e7506 100644 (file)
@@ -12,6 +12,7 @@
  *******************************************************************************/
 package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 
 /**
@@ -32,7 +33,7 @@ public interface ITmfMipmapFeature {
      * @param ts
      *            The timestamp of the event
      */
-    public void updateMipmap(ITmfStateValue value, long ts);
+    public void updateMipmap(@NonNull ITmfStateValue value, long ts);
 
     /**
      * Update the mipmap values at all levels before closing.
index 3cc2d8c83acb0480b2ec892a274f0f1bea767021..fde0c44849adb3ba4bc565c557aa5d5828892f79 100644 (file)
@@ -12,6 +12,8 @@
  *******************************************************************************/
 package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
@@ -64,6 +66,6 @@ public class MaxMipmapFeature extends TmfMipmapFeature {
         } catch (StateValueTypeException e) {
             e.printStackTrace();
         }
-        return maxValue;
+        return checkNotNull(maxValue);
     }
 }
index 6c7c3d6fd137f98b7322b15334f5fbff1fed9c49..e4a5edc2ef38baa6c108d8965d05c076531818a3 100644 (file)
@@ -12,6 +12,8 @@
  *******************************************************************************/
 package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
@@ -64,6 +66,6 @@ public class MinMipmapFeature extends TmfMipmapFeature {
         } catch (StateValueTypeException e) {
             e.printStackTrace();
         }
-        return minValue;
+        return checkNotNull(minValue);
     }
 }
index f6a1065418122e2e360c6a5efe7f98dc9132ac06..a04ffff274cc8d1338bb28c6ff5415d37000d1d3 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
@@ -34,7 +35,7 @@ import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
 public abstract class TmfMipmapFeature implements ITmfMipmapFeature {
 
     /** The current state value */
-    protected ITmfStateValue currentValue = TmfStateValue.nullValue();
+    protected @NonNull ITmfStateValue currentValue = TmfStateValue.nullValue();
     /** The current start time for the state value */
     protected long currentStartTime;
     /** The list of ongoing state intervals per mipmap level */
@@ -167,7 +168,7 @@ public abstract class TmfMipmapFeature implements ITmfMipmapFeature {
      *            The end time of the mipmap interval
      * @return A state value to be stored in the mipmap level attribute
      */
-    protected abstract ITmfStateValue computeMipmapValue(List<ITmfStateInterval> lowerIntervals, long startTime, long endTime);
+    protected abstract @NonNull ITmfStateValue computeMipmapValue(List<ITmfStateInterval> lowerIntervals, long startTime, long endTime);
 
     /**
      * Get the mipmap resolution
index 777be00e282f131a324296e39723694c38538190..9d25fbaeae8f78bd0ce1c3e955bfbbd69fa043d1 100644 (file)
@@ -285,7 +285,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
      * @return An iterable list of analysis this analyzes depends on.
      */
     protected Iterable<IAnalysisModule> getDependentAnalyses() {
-        return checkNotNull(Collections.EMPTY_LIST);
+        return Collections.EMPTY_LIST;
     }
 
     private void execute(final ITmfTrace trace) {
@@ -519,6 +519,6 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
 
     @Override
     public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
-        return checkNotNull(Collections.EMPTY_SET);
+        return Collections.EMPTY_SET;
     }
 }
index 31fdc1e157d38161f47f085e02d3d6467ffc41f2..bd78f5897f742eb5123a940851125e37dbfb4785 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.InvalidRegistryObjectException;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 
 /**
@@ -64,8 +65,8 @@ public class TmfAnalysisModuleOutputs {
      *
      * @return List of {@link ITmfNewAnalysisModuleListener}
      */
-    public static Iterable<ITmfNewAnalysisModuleListener> getOutputListeners() {
-        List<ITmfNewAnalysisModuleListener> newModuleListeners = new ArrayList<>();
+    public static Iterable<@NonNull ITmfNewAnalysisModuleListener> getOutputListeners() {
+        List<@NonNull ITmfNewAnalysisModuleListener> newModuleListeners = new ArrayList<>();
         // Get the sources element from the extension point
         IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
         for (IConfigurationElement ce : config) {
index 23f7cae944d9845df926717f39640e7d367e0fb1..098a23dd351e22ef7c2f941759a05cad045652df 100644 (file)
@@ -53,7 +53,7 @@ public class TmfAnalysisRequirement {
 
     private final String fType;
     private final Map<String, ValuePriorityLevel> fValues = new HashMap<>();
-    private final Set<String> fInformation = new HashSet<>();
+    private final Set<@NonNull String> fInformation = new HashSet<>();
 
     /**
      * The possible level for each value. They must be listed in ascending order
@@ -182,7 +182,7 @@ public class TmfAnalysisRequirement {
      * @param information
      *            The information to be added
      */
-    public void addInformation(String information) {
+    public void addInformation(@NonNull String information) {
         fInformation.add(information);
     }
 
@@ -244,7 +244,7 @@ public class TmfAnalysisRequirement {
      *
      * @return The set of all the information
      */
-    public Set<String> getInformation() {
+    public Set<@NonNull String> getInformation() {
         return fInformation;
     }
 
index e1dadb9c2731ca11eec1dc8fa26310415095036a..e9db23b1a6d5e501b933635456ae4db352a1fdc4 100644 (file)
@@ -129,7 +129,7 @@ public interface ITmfEventProvider extends ITmfComponent {
      *         an empty list if no children (return value cannot be null).
      */
     @NonNull
-    <T extends ITmfEventProvider> List<T> getChildren(Class<T> clazz);
+    <T extends ITmfEventProvider> List<@NonNull T> getChildren(Class<T> clazz);
 
     /**
      * Gets the number of children
index a20b2a9f35b39d4522c1fc39e66f70b15988ba70..6f6f4e51f95d8aaf049f9768274aea0094aefd34 100644 (file)
@@ -15,6 +15,8 @@
 
 package org.eclipse.tracecompass.tmf.core.component;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
@@ -529,11 +531,11 @@ public abstract class TmfEventProvider extends TmfComponent implements ITmfEvent
 
     @Override
     public <T extends ITmfEventProvider> List<T> getChildren(Class<T> clazz) {
-       List<T> list = new ArrayList<>();
+       List<@NonNull T> list = new ArrayList<>();
        synchronized (fChildren) {
            for (TmfEventProvider child : fChildren) {
                if (clazz.isAssignableFrom(child.getClass())) {
-                   list.add(clazz.cast(child));
+                   list.add(checkNotNull(clazz.cast(child)));
                }
            }
        }
index ee2f573df27b6f5ca566d291bcab83d4b407fe04..12efe5e99f56951504e99e865616fc047b6d60b1 100644 (file)
@@ -71,5 +71,5 @@ public interface ITmfEvent extends IAdaptable {
      * @return the name of the event, same as getType().getName()
      * @since 1.0
      */
-    String getName();
+    @NonNull String getName();
 }
index 73d0c35b9ec28a2369c7ac966e9df2afd569541f..74bbce99a59d0089c3d02b6c28ae2ed4e1a491fa 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.filter.model;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
 
 
@@ -56,7 +57,7 @@ public interface ITmfFilterTreeNode extends ITmfFilter {
      *
      * @return The array (possibly empty) of children nodes.
      */
-    public ITmfFilterTreeNode[] getChildren();
+    public @NonNull ITmfFilterTreeNode[] getChildren();
 
     /**
      * <h4>Get the node by index</h4>
index c16223a96e40156af6fb2a360dc1bbb3b232247f..85ee891371c526054791879f81995795ac2ef575 100644 (file)
@@ -18,6 +18,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 
 /**
@@ -71,8 +72,8 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
     }
 
     @Override
-    public ITmfFilterTreeNode[] getChildren() {
-        return children.toArray(new ITmfFilterTreeNode[0]);
+    public @NonNull ITmfFilterTreeNode[] getChildren() {
+        return children.toArray(new @NonNull ITmfFilterTreeNode[0]);
     }
 
     @Override
index e7a35232d79794f0f87561c9dc6bc1a5b21c0721..08b7c9c7c29111b31a0647e990f35b222b86e644 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
@@ -30,7 +32,7 @@ public abstract class CustomEventType extends TmfEventType {
      *            Trace definition
      */
     public CustomEventType(CustomTraceDefinition definition) {
-        super(definition.definitionName, getRootField(definition));
+        super(checkNotNull(definition.definitionName), getRootField(definition));
     }
 
     private static ITmfEventField getRootField(CustomTraceDefinition definition) {
index 3c2004c64ab62cf8961ff924c6add4e9c0738081..f4f6e61aa114746906179246fd5b24afb4764447 100644 (file)
@@ -520,7 +520,11 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
 
     @Override
     public Iterable<ITmfStateSystem> getStateSystems() {
-        return checkNotNull(Collections.<ITmfStateSystem> singleton(fStateSystem));
+        ITmfStateSystemBuilder stateSystem = fStateSystem;
+        if (stateSystem == null) {
+            return Collections.EMPTY_SET;
+        }
+        return Collections.singleton(stateSystem);
     }
 
     /**
index f0c4cab8adcced18c5182025d55788ebd1d068a9..71b6dd18994f14b60e25c485a97bbb6acac02c4a 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.statistics;
 import java.util.List;
 import java.util.Map;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 
 /**
@@ -64,7 +65,7 @@ public interface ITmfStatistics {
      *
      * @return The map of <event_type, count>, for the whole trace
      */
-    Map<String, Long> getEventTypesTotal();
+    Map<@NonNull String, @NonNull Long> getEventTypesTotal();
 
     /**
      * Retrieve the number of events in the trace in a given time interval.
index 4282b476d0fb720061c838762d68377f64e421bc..7c4fca784d1fa514546d64758ae10fab123a7f5b 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
@@ -104,12 +105,11 @@ public class TmfEventsStatistics implements ITmfStatistics {
     }
 
     @Override
-    public Map<String, Long> getEventTypesTotal() {
+    public Map<@NonNull String, @NonNull Long> getEventTypesTotal() {
         StatsPerTypeRequest request = new StatsPerTypeRequest(trace, TmfTimeRange.ETERNITY);
         sendAndWait(request);
 
-        Map<String, Long> stats =  request.getResults();
-        return stats;
+        return request.getResults();
     }
 
     @Override
@@ -182,7 +182,7 @@ public class TmfEventsStatistics implements ITmfStatistics {
     private class StatsPerTypeRequest extends TmfEventRequest {
 
         /* Map in which the results are saved */
-        private final Map<String, Long> stats;
+        private final Map<@NonNull String, @NonNull Long> stats;
 
         public StatsPerTypeRequest(ITmfTrace trace, TmfTimeRange range) {
             super(trace.getEventType(), range, 0, ITmfEventRequest.ALL_DATA,
@@ -190,7 +190,7 @@ public class TmfEventsStatistics implements ITmfStatistics {
             this.stats = new HashMap<>();
         }
 
-        public Map<String, Long> getResults() {
+        public Map<@NonNull String, @NonNull Long> getResults() {
             return stats;
         }
 
@@ -214,7 +214,7 @@ public class TmfEventsStatistics implements ITmfStatistics {
             }
         }
 
-        private void incrementStats(String key, long count) {
+        private void incrementStats(@NonNull String key, long count) {
             if (stats.containsKey(key)) {
                 long curValue = checkNotNull(stats.get(key));
                 stats.put(key, curValue + count);
index 9f0825d9172b118e9db19e484afdedf384e14c31..7f57fff7b7ab04fd41fe2b3d9aaea83bfe84b4d0 100644 (file)
@@ -151,8 +151,8 @@ public class TmfStateStatistics implements ITmfStatistics {
     }
 
     @Override
-    public Map<String, Long> getEventTypesTotal() {
-        final Map<String, Long> map = new HashMap<>();
+    public Map<@NonNull String, @NonNull Long> getEventTypesTotal() {
+        final Map<@NonNull String, @NonNull Long> map = new HashMap<>();
         long endTime = typesStats.getCurrentEndTime();
 
         try {
index 29f972d0d9e750faa9c9092b1c9d538574e659e6..40f044fbbe0a169d2c19bf39b41461a5b18f1824 100644 (file)
@@ -16,6 +16,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.tmf.core.component.TmfComponent;
 import org.eclipse.tracecompass.tmf.core.event.matching.ITmfEventMatching;
@@ -45,7 +46,8 @@ public abstract class SynchronizationManager extends TmfComponent {
      *            file
      * @return The synchronization object
      */
-    public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final Collection<ITmfTrace> traces, boolean doSync) {
+    public static SynchronizationAlgorithm synchronizeTraces(final File syncFile,
+            final Collection<@NonNull ITmfTrace> traces, boolean doSync) {
 
         SynchronizationAlgorithm syncAlgo;
         if (doSync) {
@@ -78,7 +80,8 @@ public abstract class SynchronizationManager extends TmfComponent {
      *            file
      * @return The synchronization object
      */
-    public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final Collection<ITmfTrace> traces, SynchronizationAlgorithm algo, boolean doSync) {
+    public static SynchronizationAlgorithm synchronizeTraces(final File syncFile,
+            final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm algo, boolean doSync) {
 
         SynchronizationAlgorithm syncAlgo;
         if (doSync) {
@@ -116,7 +119,8 @@ public abstract class SynchronizationManager extends TmfComponent {
         return null;
     }
 
-    private static SynchronizationAlgorithm synchronize(final File syncFile, final Collection<ITmfTrace> traces, SynchronizationAlgorithm syncAlgo) {
+    private static SynchronizationAlgorithm synchronize(final File syncFile,
+            final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm syncAlgo) {
         ITmfEventMatching matching = new TmfEventMatching(traces, syncAlgo);
         matching.matchEvents();
 
index 3cfee8a6771e688c6bff976f2f85d3815ae59827..8948bca04302e259aa7f5baf29fe6fb89336dd31 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -78,7 +80,7 @@ public final class TmfTraceUtils {
         Set<@NonNull T> modules = new HashSet<>();
         for (IAnalysisModule module : analysisModules) {
             if (moduleClass.isAssignableFrom(module.getClass())) {
-                modules.add(moduleClass.cast(module));
+                modules.add(checkNotNull(moduleClass.cast(module)));
             }
         }
         return modules;
index 59e1405beffbebd62abfdf8d18ac3aa67e528925..b2e3cea3a9462e4f73e7fcabf79c646716d784bc 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentContext;
@@ -242,7 +243,7 @@ public class TmfExperiment extends TmfTrace implements ITmfPersistentlyIndexable
      *
      * @return The array of contained traces
      */
-    public List<ITmfTrace> getTraces() {
+    public List<@NonNull ITmfTrace> getTraces() {
         return getChildren(ITmfTrace.class);
     }
 
@@ -525,7 +526,7 @@ public class TmfExperiment extends TmfTrace implements ITmfPersistentlyIndexable
 
             final File syncFile = (syncDirectory != null) ? new File(syncDirectory + File.separator + SYNCHRONIZATION_FILE_NAME) : null;
 
-            final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Collections.<ITmfTrace> singleton(this), doSync);
+            final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Collections.singleton(this), doSync);
 
             final TmfTraceSynchronizedSignal signal = new TmfTraceSynchronizedSignal(this, syncAlgo);
 
index 769c29c3a56289abbab02b44a69d8849c7af163d..bbd60c9054046cd96418b6e5ac08805f2d061c42 100644 (file)
@@ -13,8 +13,6 @@
 
 package org.eclipse.tracecompass.tmf.core.trace.text;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -81,7 +79,7 @@ public class TextTraceEventContent implements ITmfEventField {
     private TextTraceEventContent(@NonNull String fieldName) {
         fName = fieldName;
         fValue = null;
-        fFields = checkNotNull(Collections.EMPTY_LIST);
+        fFields = Collections.EMPTY_LIST;
     }
 
     // ------------------------------------------------------------------------
index 3b40a01bc785a6f40c8a7ec8ef1a300ffcf3cd21..56097510b7e45a332de3a77331393ef54f0a5195 100644 (file)
@@ -26,9 +26,9 @@ import org.junit.Test;
  */
 public class CommandResultTest {
 
-    private static final String @NonNull [] CMD_OUTPUT = { "This", "is", "the", "output" };
-    private static final String @NonNull [] CMD_NO_ERROR_OUTPUT = {};
-    private static final String @NonNull [] CMD_ERROR_OUTPUT = { "This", "is", "the", "error", "output" };
+    private static final @NonNull String @NonNull [] CMD_OUTPUT = { "This", "is", "the", "output" };
+    private static final @NonNull String @NonNull [] CMD_NO_ERROR_OUTPUT = {};
+    private static final @NonNull String @NonNull [] CMD_ERROR_OUTPUT = { "This", "is", "the", "error", "output" };
 
     /**
      * Test suite for the {@link CommandResult} class
index 27065c0024bc21ad46297df5a3a269a3cfe4feac..03b2be25e8bec046d9b6f2193a641afd4499d159 100644 (file)
@@ -39,9 +39,9 @@ public class CommandShellTest {
 
     private static final boolean IS_UNIX = !Platform.getOS().equals(Platform.OS_WIN32);
 
-    private static final String @NonNull [] CMD_INPUT_UNIX = { "ls", "-l" };
-    private static final String @NonNull [] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
-    private static final String @NonNull [] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
+    private static final @NonNull String @NonNull [] CMD_INPUT_UNIX = { "ls", "-l" };
+    private static final @NonNull String @NonNull [] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
+    private static final @NonNull String @NonNull [] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
 
     private static final IRemoteConnection LOCAL_CONNECTION = TmfRemoteConnectionFactory.getLocalConnection();
     private static final RemoteSystemProxy LOCAL_PROXY = new RemoteSystemProxy(checkNotNull(LOCAL_CONNECTION));
index 63d94f4d75164678091a476eae7dbad63a8c34a3..4c0037b3377b245ad522fb050bba75411f5aba01 100644 (file)
@@ -14,7 +14,9 @@ package org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells;
 
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput;
 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandResult;
 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
@@ -25,6 +27,7 @@ import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
 /**
  * Command shell stub
  */
+@NonNullByDefault
 public class TestCommandShell implements ICommandShell {
 
     /** If the shell is connected */
@@ -36,16 +39,17 @@ public class TestCommandShell implements ICommandShell {
     }
 
     @Override
-    public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor) throws ExecutionException {
+    public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor) throws ExecutionException {
         return executeCommand(command, monitor, null);
     }
 
     @Override
-    public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor, ICommandOutputListener listener) throws ExecutionException {
+    public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor,
+            @Nullable ICommandOutputListener listener) throws ExecutionException {
         if (fIsConnected) {
-            return createCommandResult(0, new String[0], new String[0]);
+            return createCommandResult(0, new @NonNull String[0], new @NonNull String[0]);
         }
-        return createCommandResult(1, new String[0], new String[0]);
+        return createCommandResult(1, new @NonNull String[0], new @NonNull String[0]);
     }
 
     @Override
@@ -64,8 +68,7 @@ public class TestCommandShell implements ICommandShell {
      *            THe error output as an array of strings
      * @return {@link ICommandResult} instance
      */
-    @NonNullByDefault
-    protected ICommandResult createCommandResult(int result, String[] output, String[] errorOutput) {
+    protected ICommandResult createCommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) {
         return new CommandResult(result, output, errorOutput);
     }
-}
\ No newline at end of file
+}
index 8bc9d4ab12af621b11282c69685d9e73b2f740be..27e8b5a811864fcf8553468bad3e58589b3affbf 100644 (file)
  **********************************************************************/
 package org.eclipse.tracecompass.internal.tmf.remote.core.shell;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandResult;
 
@@ -55,10 +55,10 @@ public class CommandResult implements ICommandResult {
      * @param errorOutput
      *            THe error output as an array of strings
      */
-    public CommandResult(int result, String[] output, String[] errorOutput) {
+    public CommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) {
         fResult = result;
-        fOutput = checkNotNull(ImmutableList.copyOf(output));
-        fErrorOutput = checkNotNull(ImmutableList.copyOf(errorOutput));
+        fOutput = ImmutableList.copyOf(output);
+        fErrorOutput = ImmutableList.copyOf(errorOutput);
     }
 
     // ------------------------------------------------------------------------
index 82b0911fcbccf42e325ce4f8de4025890b1d6ec6..42b9fab04595cecd3ec82ce90c4600b141fefab7 100644 (file)
@@ -115,14 +115,15 @@ public class CommandShell implements ICommandShell {
                             }
                         } catch (OperationCanceledException e) {
                         } catch (InterruptedException e) {
-                            return new CommandResult(1, new String[0], new String[] {e.getMessage()});
+                            return new CommandResult(1, new @NonNull String[0],
+                                    new @NonNull String[] { checkNotNull(e.getMessage()) });
                         } finally {
                             stdout.stop();
                             stderr.stop();
                             process.destroy();
                         }
                     }
-                    return new CommandResult(1, new String[0], new String[] {"cancelled"}); //$NON-NLS-1$
+                    return new CommandResult(1, new @NonNull String[0], new @NonNull String[] { "cancelled" }); //$NON-NLS-1$
                 }
             });
 
@@ -154,12 +155,12 @@ public class CommandShell implements ICommandShell {
         result = origResult;
         stdout = origStdout;
         stderr = origStderr;
-        String[] output = splitLines(stdout);
-        String[] error = splitLines(stderr);
+        @NonNull String[] output = splitLines(stdout);
+        @NonNull String[] error = splitLines(stderr);
         return new CommandResult(result, output, error);
     }
 
-    private static String @NonNull [] splitLines(String output) {
-        return checkNotNull(output.split("\\r?\\n")); //$NON-NLS-1$
+    private static @NonNull String @NonNull [] splitLines(String output) {
+        return output.split("\\r?\\n"); //$NON-NLS-1$
     }
 }
index 4b3f7349435822fe77591a8b2e82915089d85c7c..c602684c67a32ce3ba05cbc57affda246dd740ea 100644 (file)
@@ -53,7 +53,10 @@ public class TmfRemoteConnectionFactory {
         // Add local services
         IRemoteServicesManager manager = getService(IRemoteServicesManager.class);
         if (manager != null) {
-            CONNECTION_FACTORIES.put(manager.getLocalConnectionType().getId(), new LocalConnectionFactory());
+            IRemoteConnectionType type = manager.getLocalConnectionType();
+            if (type != null) {
+                CONNECTION_FACTORIES.put(checkNotNull(type.getId()), new LocalConnectionFactory());
+            }
         }
     }
 
index ed962f12d268400600b6734eb89171825bdaddfc..2b13bda80d011fed2d0946e5c9fbba9dcd63538f 100644 (file)
@@ -29,6 +29,7 @@ import javax.xml.validation.Validator;
 
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.importexport.ManifestReader;
@@ -48,7 +49,8 @@ public class RemoteImportProfilesReader {
 
     private static final String SCHEMA_FOLDER_NAME = "schema"; //$NON-NLS-1$
     private static final String PROFILES_SCHEMA_FILE_NAME = "remote-profile.xsd"; //$NON-NLS-1$
-    private static final TracePackageElement[] EMPTY_ARRAY = new TracePackageElement[0];
+    private static final @NonNull TracePackageElement @NonNull [] EMPTY_ARRAY =
+            new @NonNull TracePackageElement[0];
 
     /**
      * Validate the content of the profiles file from an input stream
index 7c3455c7e8c5e8bd242a62e3bc9a42f35c589862..1570a14a8d732841970aa8d8ea43483fdb6fc2f2 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.log4j.ConsoleAppender;
 import org.apache.log4j.Logger;
 import org.apache.log4j.SimpleLayout;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
@@ -102,7 +103,7 @@ public class ColorsViewTest {
         }
 
         @Override
-        public ITmfFilterTreeNode[] getChildren() {
+        public @NonNull ITmfFilterTreeNode[] getChildren() {
             return null;
         }
 
index 4b16c75a0ab29e71edaa0de7417a0f6263882ca4..959a07fe680fcb4ad455c736d094f43e34aefd71 100644 (file)
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
@@ -57,8 +58,8 @@ public class TmfBaseColumnDataProviderTest {
 
     private static final String fTestName = "ColumnDataProviderTest";
 
-    private final String fTypeId1 = "Some type1";
-    private final String fTypeId2 = "Some type2";
+    private final @NonNull String fTypeId1 = "Some type1";
+    private final @NonNull String fTypeId2 = "Some type2";
 
     private final String fLabel0 = "label1";
     private final String fLabel1 = "label2";
index 04934b971b3311441f885b462108afe3bbc27431..4328b2c2c5a37134efcafab933977c241e708b78 100755 (executable)
@@ -25,6 +25,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Vector;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
@@ -48,8 +49,8 @@ public class TmfBaseStatisticsDataTest {
 
     private static final String fTestName = "StatisticsDataTest";
 
-    private final String fTypeId1 = "Some type1";
-    private final String fTypeId2 = "Some type2";
+    private final @NonNull String fTypeId1 = "Some type1";
+    private final @NonNull String fTypeId2 = "Some type2";
 
     private final String   fLabel0 = "label1";
     private final String   fLabel1 = "label2";
index 961b71211840f0aad5619455e4f9f94ba75ef616..fa9f73cf9c754a4ce28c64fb50c52434dfe41ffb 100755 (executable)
@@ -22,6 +22,7 @@ import static org.junit.Assert.fail;
 
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
@@ -46,8 +47,8 @@ public class TmfTreeContentProviderTest {
 
     private static final String fTestName = "TreeContentProviderTest";
 
-    private final String fTypeId1 = "Some type1";
-    private final String fTypeId2 = "Some type2";
+    private final @NonNull String fTypeId1 = "Some type1";
+    private final @NonNull String fTypeId2 = "Some type2";
 
     private final String fLabel0 = "label1";
     private final String fLabel1 = "label2";
index 3deb4ba1debe6b81a9691796cdb5674499eea7d2..62ccbd9ad6235f5903bb9faf67a5b2d0f709a346 100644 (file)
@@ -31,6 +31,7 @@ import javax.xml.validation.Validator;
 
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.ITracePackageConstants;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement;
@@ -55,7 +56,8 @@ public class ManifestReader {
 
     private static final String SCHEMA_FOLDER_NAME = "schema"; //$NON-NLS-1$
     private static final String EXPORT_MANIFEST_SCHEMA_FILE_NAME = "export-manifest.xsd"; //$NON-NLS-1$
-    private static final TracePackageElement [] EMPTY_ARRAY = new TracePackageElement[0];
+    private static final @NonNull TracePackageElement @NonNull [] EMPTY_ARRAY =
+            new @NonNull TracePackageElement[0];
 
     /**
      * Validate the content of a manifest from an input stream
index 751e36e2698b5bbd1849f3f708e96afe5749bcb7..8c6635f9826e1e719a961815ef4b4c17ada01c16 100644 (file)
@@ -186,9 +186,7 @@ public class SelectRootNodeWizardPage extends WizardPage {
                 traces.add((TmfTraceElement) sel);
             }
         }
-        TmfTraceElement[] result = new TmfTraceElement[traces.size()];
-        traces.toArray(result);
-        return result;
+        return traces.toArray(new @NonNull TmfTraceElement[0]);
     }
 
     /**
index e22c5da36cda5483700e7adc8bdcf702471bca8b..1bb99ccfb4ff7d68f0a7aa87e3826bc438fc3eb3 100644 (file)
@@ -475,9 +475,7 @@ public class SelectTracesWizardPage extends WizardPage {
                 traces.add((TmfTraceElement) sel);
             }
         }
-        TmfTraceElement[] result = new TmfTraceElement[traces.size()];
-        traces.toArray(result);
-        return result;
+        return traces.toArray(new @NonNull TmfTraceElement[0]);
     }
 
 }
index a93eb88099d662cb47922373087a3151f6c5b2f0..693b660d20af65d8d60359daf8fc4f23ef6408fd 100644 (file)
@@ -255,6 +255,9 @@ public class TmfEventPropertySource implements IPropertySource {
 
         @Override
         public Object getPropertyValue(Object id) {
+            if (!(id instanceof String)) {
+                return null;
+            }
             return event.getCustomAttribute((String) id);
         }
 
index 7efcf62539c90017fcca3995fe15e660f61b03fc..5f2ba301c63615eda601d63595103fd441ad4353 100644 (file)
@@ -20,6 +20,7 @@ import java.io.IOException;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode;
 import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterRootNode;
@@ -89,7 +90,7 @@ public class FilterManager {
      *
      * @return The array of filters
      */
-    public static ITmfFilterTreeNode[] getSavedFilters() {
+    public static @NonNull ITmfFilterTreeNode[] getSavedFilters() {
         return fRoot.clone().getChildren();
     }
 
This page took 0.132061 seconds and 5 git commands to generate.