fixed NPE if no UploadProgress object is stored for uploadId in (#780)
Fixed NPE if no UploadProgress object is stored for uploadId in artifactUploadState. Signed-off-by: Markus Block <markus.block@bosch-si.com>
This commit is contained in:
committed by
Stefan Behl
parent
da098b334b
commit
5025192844
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.artifacts.upload;
|
package org.eclipse.hawkbit.ui.artifacts.upload;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.upload.FileUploadProgress.FileUploadStatus;
|
import org.eclipse.hawkbit.ui.artifacts.upload.FileUploadProgress.FileUploadStatus;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
@@ -18,6 +17,7 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
@@ -328,11 +328,7 @@ public class UploadProgressInfoWindow extends Window {
|
|||||||
status = STATUS_INPROGRESS;
|
status = STATUS_INPROGRESS;
|
||||||
}
|
}
|
||||||
item.getItemProperty(COLUMN_STATUS).setValue(status);
|
item.getItemProperty(COLUMN_STATUS).setValue(status);
|
||||||
|
item.getItemProperty(COLUMN_REASON).setValue(getFailureReason(fileUploadId));
|
||||||
final String failureReason = artifactUploadState.getFileUploadProgress(fileUploadId).getFailureReason();
|
|
||||||
if (StringUtils.isNotBlank(failureReason)) {
|
|
||||||
item.getItemProperty(COLUMN_REASON).setValue(failureReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
final long bytesRead = fileUploadProgress.getBytesRead();
|
final long bytesRead = fileUploadProgress.getBytesRead();
|
||||||
final long fileSize = fileUploadProgress.getContentLength();
|
final long fileSize = fileUploadProgress.getContentLength();
|
||||||
@@ -340,4 +336,22 @@ public class UploadProgressInfoWindow extends Window {
|
|||||||
item.getItemProperty(COLUMN_PROGRESS).setValue((double) bytesRead / (double) fileSize);
|
item.getItemProperty(COLUMN_PROGRESS).setValue((double) bytesRead / (double) fileSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the failure reason for the provided fileUploadId or an empty
|
||||||
|
* string but never <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param fileUploadId
|
||||||
|
* @return the failure reason or an empty String.
|
||||||
|
*/
|
||||||
|
private String getFailureReason(final FileUploadId fileUploadId) {
|
||||||
|
String failureReason = "";
|
||||||
|
if (artifactUploadState.getFileUploadProgress(fileUploadId) != null) {
|
||||||
|
failureReason = artifactUploadState.getFileUploadProgress(fileUploadId).getFailureReason();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(failureReason)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return failureReason;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user