AbstractField.getConversionError throws null pointer exception

I am using Vaadin 7.1.8, but I’m not sure when this issue popped up. If I put invalid data into a TextField that is associated with a model object of mine (I provide a converter between the model object and the field’s String representation) as well as a validator. Here’s the exception stack trace:

        at java.lang.String.replace(String.java:2180)
        at com.vaadin.ui.AbstractField.getConversionError(AbstractField.java:791)
        at com.vaadin.ui.AbstractField.validate(AbstractField.java:952)
        at com.vaadin.ui.AbstractField.validate(AbstractField.java:927)
        at com.vaadin.ui.AbstractField.getErrorMessage(AbstractField.java:1036)
        at com.vaadin.ui.AbstractComponent.beforeClientResponse(AbstractComponent.java:671)
        at com.vaadin.ui.AbstractField.beforeClientResponse(AbstractField.java:1694)
        at com.vaadin.ui.AbstractTextField.beforeClientResponse(AbstractTextField.java:100)
        at com.vaadin.server.communication.UidlWriter.write(UidlWriter.java:96)
        at com.vaadin.server.communication.UidlRequestHandler.writeUidl(UidlRequestHandler.java:149)
        at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:97)
        at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
        at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
        at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

What I discovered is that the AbstractField.getConversionError() is called from AbstractField.converToModel(). But my converter attempts to do it, and if it cannot it just throws an empty conversion exception:

throw new com.vaadin.data.util.converter.Converter.ConversionException();

This previously worked. I know I grumbled before that I couldn’t set a message in the converter, but back in 7.0 that was the case and so I have a Converter as well as a Validator and the Converter doesn’t attempt to set a message. I can remove the null pointer exception if I pass in an empty string to ConversionException, but this should not be necessary.

The buggy code is in AbstractField.getConversionError() when it checks if ‘e’ is null, but without care about whether e.getLocalizedMessage() is null for the {1} replacement. It probably should be something like:

    protected String getConversionError(Class<?> dataSourceType,
            ConversionException e) {
        String conversionError = getConversionError();

        if (dataSourceType != null) {
            conversionError = conversionError.replace("{0}",
        if (e != null) {
            String localizedMessage = e.getLocalizedMessage();
            if (localizedMessage != null) {
                conversionError = conversionError.replace("{1}", localizedMessage);

        return conversionError;

Hi David,
I reported the error (
NPE is thrown, when ConversionException has no message
) three weeks ago, but nobody has reacted yet :frowning:

Glad you created the ticket 12962 for this. Figured that was next…

It’s an easy fix that I even gave them the code, so hopefully they’ll just fix this for the next 7.1.9 release – it’s a clear coding error because the constructor for the exception does not require a message and the using of that object needs to check if it’s null before using it.