commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barney Barumba (JIRA)" <>
Subject [jira] [Created] (DIGESTER-180) Digester calls invalid method when using proxy ObjectCreate rule
Date Tue, 23 Dec 2014 16:53:13 GMT
Barney Barumba created DIGESTER-180:

             Summary: Digester calls invalid method when using proxy ObjectCreate rule
                 Key: DIGESTER-180
             Project: Commons Digester
          Issue Type: Bug
    Affects Versions: 3.2
         Environment: Linux x_86_64, JDK 1.7.0_65
            Reporter: Barney Barumba

Hi, I've encountered some strange behaviour when using the new proxy object create: the digester
appears to call a method that is never mentioned in the digester rules! I've simplified it
as much as I can to the following (full, runnable code attached):

A simple box of widgets:

  private final String id;
  private final Set<String> widgetIds = new HashSet<>();
  public Box(String id) {
    System.out.println("Box: id=" + id); = id;
  public void addWidget(String widgetId) {
    System.out.println("addWidget: id=" + id + ", wid=" + widgetId);
  public void addWidgetInternal(String widgetId) {
    System.out.println("addWidgetInternal: id=" + id + ", wid=" + widgetId);
    if (widgetIds.contains(widgetId)) {
      System.err.println("*** box already contains widget " + widgetId);
    } else {

The source XML is fairly straightforward:
<box id='b01'>
  <widget wid='w01'>Widget 1</widget>

as are the rules:

The key point here is that the rules only ever invoke {{addWidget}}, and this calls {{addWidgetInternal}}.
However, when I run this, {{addWidgetInternal}} gets called twice, the second time directly
from the digester, and I get the following output:

Box: id=
addWidget: id=, wid=w01
addWidgetInternal: id=, wid=w01
Box: id=b01
addWidget: id=b01, wid=w01
addWidgetInternal: id=b01, wid=w01
addWidgetInternal: id=b01, wid=w01
*** box already contains widget w01

I'm guessing that this is connected with the proxy code because I can change any number of
things to make it work:
* Make {{addWidgetInternal}} private;
* Call {{addWidgetInternal}} directly from the digester rules.
* Use a custom object create rule instead (see attached code).

This message was sent by Atlassian JIRA

View raw message