Skip to content

Commit

Permalink
Merge pull request WebGoat#36 from nbaars/master
Browse files Browse the repository at this point in the history
Fixed not serializable error when stopping/starting Tomcat
  • Loading branch information
mayhew64 committed Aug 23, 2015
2 parents 9b4c97e + 69350a6 commit 06d025d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

package org.owasp.webgoat.util;

import java.util.Locale;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import java.io.Serializable;
import java.util.Locale;


/***************************************************************************************************
*
Expand Down Expand Up @@ -37,14 +39,20 @@
*/
@Component("labelManager")
@Scope(value="session", proxyMode=ScopedProxyMode.INTERFACES)
public class LabelManagerImpl implements LabelManager
public class LabelManagerImpl implements LabelManager, Serializable
{
@Resource
private LabelProvider labelProvider;
private transient LabelProvider labelProvider;

/** Locale mapped with current session. */
private Locale locale = new Locale(LabelProvider.DEFAULT_LANGUAGE);

protected LabelManagerImpl() {}

@Inject
public LabelManagerImpl(LabelProvider labelProvider) {
this.labelProvider = labelProvider;
}

public void setLocale(Locale locale)
{
if (locale != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.owasp.webgoat.util;

import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class LabelManagerImplTest {

@Test
public void shouldSerialize() throws IOException {
LabelManagerImpl labelManager = new LabelManagerImpl(null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(labelManager);
}

@Test
public void shouldSerializeWithLabelProvider() throws IOException {
LabelManagerImpl labelManager = new LabelManagerImpl(new LabelProvider());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(labelManager);
}
}

0 comments on commit 06d025d

Please sign in to comment.