CCM NG/ccm-core: MimeTypeConverter was not null safe

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4393 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-10-19 18:05:53 +00:00
parent a87adf35fa
commit e68a5ba5d2
1 changed files with 6 additions and 5 deletions

View File

@ -18,7 +18,6 @@
*/ */
package org.libreccm.jpa.utils; package org.libreccm.jpa.utils;
import javax.activation.MimeType; import javax.activation.MimeType;
import javax.activation.MimeTypeParseException; import javax.activation.MimeTypeParseException;
import javax.persistence.AttributeConverter; import javax.persistence.AttributeConverter;
@ -27,7 +26,7 @@ import javax.persistence.Converter;
/** /**
* A converter for converting properties of the type {@link MimeType} to * A converter for converting properties of the type {@link MimeType} to
* {@code String}. * {@code String}.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Converter(autoApply = true) @Converter(autoApply = true)
@ -35,7 +34,11 @@ public class MimeTypeConverter implements AttributeConverter<MimeType, String> {
@Override @Override
public String convertToDatabaseColumn(final MimeType attribute) { public String convertToDatabaseColumn(final MimeType attribute) {
return attribute.toString(); if (attribute == null) {
return null;
} else {
return attribute.toString();
}
} }
@Override @Override
@ -46,7 +49,5 @@ public class MimeTypeConverter implements AttributeConverter<MimeType, String> {
throw new IllegalArgumentException("Not a valid mime type", ex); throw new IllegalArgumentException("Not a valid mime type", ex);
} }
} }
} }