Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
rh-che #1488: Adding NPE check in the 'FactoryUrlSetterInterceptor' t…
Browse files Browse the repository at this point in the history
…o avoid failures of workspaces started from devfile

Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
  • Loading branch information
ibuziuk committed Jul 23, 2019
1 parent 77caf24 commit 4f5dead
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto;

/**
* This interceptor must be bound for the method {@link
Expand All @@ -32,11 +33,14 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
@SuppressWarnings("unchecked")
final Map<String, String> parameters = (Map<String, String>) args[0];
FactoryDto factory = (FactoryDto) invocation.proceed();
Map<String, String> attributes = factory.getWorkspace().getAttributes();
parameters.forEach(
(k, v) -> {
attributes.put("factory.parameter." + k, v);
});
WorkspaceConfigDto workspace = factory.getWorkspace();
if (workspace != null) {
Map<String, String> attributes = workspace.getAttributes();
parameters.forEach(
(k, v) -> {
attributes.put("factory.parameter." + k, v);
});
}
return factory;
}
}

0 comments on commit 4f5dead

Please sign in to comment.