Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmf: Fix stream orElse(null) errors #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 École Polytechnique de Montréal
* Copyright (c) 2015, 2024 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -96,8 +96,8 @@ public String getHostId() {
return Collections.emptyMap();
}
ImmutableMap.Builder<String, String> workerInfo = new Builder<>();
workerInfo.put(OsStrings.tid(), String.valueOf(tid)); //$NON-NLS-1$
Optional<@Nullable KernelAnalysisModule> kam = TmfTraceManager.getInstance().getActiveTraceSet()
workerInfo.put(OsStrings.tid(), String.valueOf(tid));
Optional<@NonNull KernelAnalysisModule> kam = TmfTraceManager.getInstance().getActiveTraceSet()
.stream()
.filter(trace -> trace.getHostId().equals(getHostId()))
.map(trace -> TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 École Polytechnique de Montréal
* Copyright (c) 2016, 2024 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -114,19 +114,20 @@ public Collection<AggregatedCallSite> getSamplingData(int tid, long start, long

@Override
public int getProcessId(int tid, long t) {
Integer pid = fKernelModules.stream()
Optional<Integer> pid = fKernelModules.stream()
.map(module -> KernelThreadInformationProvider.getProcessId(module, tid, t))
.filter(Objects::nonNull)
.findFirst().orElse(null);
return pid == null ? IHostModel.UNKNOWN_TID : (int) pid;
.findFirst();
return pid.isEmpty() ? IHostModel.UNKNOWN_TID : pid.get();
}

@Override
public @Nullable String getExecName(int tid, long t) {
return fKernelModules.stream()
Optional<String> execName = fKernelModules.stream()
.map(module -> KernelThreadInformationProvider.getExecutableName(module, tid))
.filter(Objects::nonNull)
.findFirst().orElse(null);
.findFirst();
return execName.isPresent() ? execName.get() : null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<skip-short-tc-ui-tests>false</skip-short-tc-ui-tests>
<skip-long-tc-ui-tests>false</skip-long-tc-ui-tests>

<tycho-version>4.0.3</tycho-version>
<tycho-extras-version>4.0.3</tycho-extras-version>
<tycho-version>4.0.9</tycho-version>
<tycho-extras-version>4.0.9</tycho-extras-version>
<tycho-use-project-settings>true</tycho-use-project-settings>
<tycho.scmUrl>scm:git:https://github.com/eclipse-tracecompass/org.eclipse.tracecompass</tycho.scmUrl>
<cbi-plugins.version>1.4.2</cbi-plugins.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Ericsson
* Copyright (c) 2015, 2024 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand All @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -228,12 +229,12 @@ private static IRemoteConnectionType getConnectionType(URI hostUri) throws Remot
if (manager == null) {
return null;
}
return manager.getAllRemoteConnections().stream()
Optional<IRemoteConnection> remoteConnection = manager.getAllRemoteConnections().stream()
.filter(Objects::nonNull)
.filter(connection -> connection.getName().equals(name))
.filter(connection -> connection.getConnectionType().getId().equals(remoteServicesId))
.findFirst()
.orElse(null);
.findFirst();
return remoteConnection.isPresent() ? remoteConnection.get() : null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
Expand Down Expand Up @@ -189,11 +190,11 @@ public List<TmfExperimentElement> getExperiments() {
* @since 2.0
*/
public @Nullable TmfExperimentElement getExperiment(@NonNull String name) {
return getExperiments().stream()
Optional<@NonNull TmfExperimentElement> exp = getExperiments().stream()
.filter(Objects::nonNull)
.filter(experiment -> experiment.getName().equals(name))
.findFirst()
.orElse(null);
.findFirst();
return exp.isPresent() ? exp.get() : null;
}


Expand Down
Loading