Skip to content

Commit

Permalink
BUG inside restoreState: Object[].length is 2!
Browse files Browse the repository at this point in the history
Generics
Cosmetics

Signed-off-by: pizzi80 <[email protected]>
  • Loading branch information
pizzi80 committed Dec 17, 2022
1 parent 2395077 commit a983e27
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ protected FacesListener[] getFacesListeners(Class clazz) {
}

@Override
protected Renderer getRenderer(FacesContext context) {
protected Renderer<? extends UIComponent> getRenderer(FacesContext context) {
return null;
}

Expand Down
13 changes: 7 additions & 6 deletions impl/src/main/java/jakarta/faces/component/StateHolderSaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package jakarta.faces.component;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;

import jakarta.faces.context.FacesContext;

Expand Down Expand Up @@ -100,7 +101,7 @@ public StateHolderSaver(FacesContext context, Object toSave) {

public Object restore(FacesContext context) throws IllegalStateException {
Object result = null;
Class toRestoreClass;
Class<?> toRestoreClass;

// if the Object to save implemented Serializable but not
// StateHolder
Expand All @@ -124,11 +125,11 @@ public Object restore(FacesContext context) throws IllegalStateException {

if (null != toRestoreClass) {
try {
result = toRestoreClass.newInstance();
} catch (InstantiationException e) {
result = toRestoreClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (IllegalAccessException a) {
throw new IllegalStateException(a);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}

Expand All @@ -141,7 +142,7 @@ public Object restore(FacesContext context) throws IllegalStateException {
return result;
}

private static Class loadClass(String name, Object fallbackClass) throws ClassNotFoundException {
private static Class<?> loadClass(String name, Object fallbackClass) throws ClassNotFoundException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = fallbackClass.getClass().getClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ public void processEvent(ComponentSystemEvent event) throws AbortProcessingExcep
* @param context {@link FacesContext} for the current request
* @return the renderer, or <code>null</code>.
*/
protected abstract Renderer getRenderer(FacesContext context);
protected abstract Renderer<? extends UIComponent> getRenderer(FacesContext context);

// --------------------------------------------------------- Package Private

Expand Down
Loading

0 comments on commit a983e27

Please sign in to comment.