Skip to content

Failed to get file status with empty MIME type #10

@qinlan1021

Description

@qinlan1021
/**
 * Get file status without file stream.
 *
 * @param fileId File id.
 * @return File status.
 * @throws IOException Http connection is fail or server response within some error message.
 */
public FileHandleStatus getFileStatus(String fileId) throws IOException {
    final String targetUrl = getTargetUrl(fileId);
    HeaderResponse headerResponse = volumeWrapper.getFileStatusHeader(targetUrl, fileId);
    try {
        return new FileHandleStatus(fileId,
                headerDateFormat.parse(headerResponse.getLastHeader("Last-Modified").getValue()).getTime(),
                headerResponse.getLastHeader("Content-Disposition").getValue()
                        .substring(10, headerResponse.getLastHeader("Content-Disposition").getValue().length() - 1),
                headerResponse.getLastHeader("Content-Type").getValue(),
                Long.parseLong(headerResponse.getLastHeader("Content-Length").getValue()));
    } catch (ParseException e) {
        throw new SeaweedfsException("Could not parse last modified time [" +
                headerResponse.getLastHeader("Last-Modified").getValue() + "] to long value");
    }
}

headerResponse.getLastHeader("Content-Type").getValue() Raises java.lang.NullPointerException when the MIME type is empty in file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions