Hi @all!

Since Java 7 has reached end of support we did switch to Java 8 within
our application. Since Java 8 it is possible to setup default methods
within interfaces [1].
We do have multiple DAOs which do implement the same interface. Before
Java 8 we had to implement the same method in each class the same way.
After migrating to Java 8 we moved this method up as the defult method
to the interface.

Now comes the Bug within Tapestry SelectModelFactory:
Since the Method now resides within the interface
SelectModelFactory#create fails to instantiate this method and throws
a nullpointerexception.

The only way to circumvent this currently is to also implement the
method within all of the interface implementing class (as with Java 7).

Here a snippet from interface and non working SelectModelFactory#create:

-----------------------------------------------------------------------

public interface User extends Serializable, TransferObject, Principal {
[...]
        @NonVisual
        default String getFullNameWithMailAddress(){
                StringBuilder sb = new StringBuilder();
                sb.append(getFullName());
                if (!getMailAddress().isEmpty()) {
                        sb.append(" (");
                        sb.append(getMailAddress());
                        sb.append(")");
                }
                return sb.toString();
        }
[...]
}
public class AuthorList {
[...]
public SelectModel getAssociatesModel() {
                List<User> associates = new ArrayList<>(getAssociates());
                return selectModelFactory.create(associates,
"fullNameWithMailAddress"); // throws NPE
        }
[...]
}

[1] https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html





Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to