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

Avoid NPE during instrumentation #8317

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -72,7 +72,7 @@ public final class ExecutionService {
private final EnsoContext context;
private final Optional<IdExecutionService> idExecutionInstrument;
private final NotificationHandler.Forwarder notificationForwarder;
private final TruffleLogger logger = TruffleLogger.getLogger(LanguageInfo.ID);
private final TruffleLogger logger = TruffleLogger.getLogger(LanguageInfo.ID, ExecutionService.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice observation. Those [enso] ... log messages were confusing

private final ConnectedLockManager connectedLockManager;
private final ExecuteRootNode execute = new ExecuteRootNode();
private final CallRootNode call = new CallRootNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void onReturnValue(VirtualFrame frame, Object result) {
functionCallInstrumentationNode.getId(),
result,
nanoTimeElapsed,
frame.materialize(),
frame == null ? null : frame.materialize(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin ?. safe call operator would be handy here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do: Optional.of(frame).map(f -> f.materialize()).getOrNull() to get more functional feeling.

node);
Object cachedResult = callbacks.onFunctionReturn(info);
if (cachedResult != null) {
Expand All @@ -243,7 +243,7 @@ public void onReturnValue(VirtualFrame frame, Object result) {
} else if (node instanceof ExpressionNode expressionNode) {
Info info =
new NodeInfo(
expressionNode.getId(), result, nanoTimeElapsed, frame.materialize(), node);
expressionNode.getId(), result, nanoTimeElapsed, frame == null ? null : frame.materialize(), node);
callbacks.updateCachedResult(info);

if (info.isPanic()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private ApplicationFilter(LoggersLevels loggers, Level level, String prefix) {
this.loggers = loggers;
this.level = level;
this.prefix = prefix;
this.prefixLength = prefix != null ? prefix.length() + 1 : 0; // inlude `.` in `enso.`
this.prefixLength = prefix != null ? prefix.length() : 0;
}

@Override
Expand All @@ -48,7 +48,12 @@ public FilterReply decide(ILoggingEvent event) {

private boolean loggerNameMatches(String validLoggerName, String eventLoggerName) {
if (prefix != null && eventLoggerName.startsWith(prefix)) {
return eventLoggerName.substring(prefixLength).startsWith(validLoggerName);
String prefixLessLoggerName = eventLoggerName.substring(prefixLength);
String normalizedLoggerName =
prefixLessLoggerName.startsWith(".")
? prefixLessLoggerName.substring(1)
: prefixLessLoggerName;
return normalizedLoggerName.startsWith(validLoggerName);
} else {
return eventLoggerName.startsWith(validLoggerName);
}
Expand Down
Loading