Search code examples
javaweb-applicationscoding-stylestruts-1

Odd Java bug I can't seem to resolve


I'm scratching my head as to why some code within my try statement isn't being executed. Below is the culprit code in question.

try {
    Long idSociety = UtilAction.<Long>getSessionAttribute(session, idSocietyAttrName);
    ContactAddressForm caf = (ContactAddressForm) form;
    java.lang.System.out.println("invoiceAddresss: " + caf.getInvoiceAddress()); //This doesn't show in Console
    Address address = new Address(caf.getStreet(), caf.getPostalCode(), caf.getCity(), caf.getBoitePostale());
    ContactAddress ca = new ContactAddress();

    ca.setInvoiceAddress(caf.getInvoiceAddress()); //Not set despite the Debugger showing the correct value for caf.
    ca.setAddress(address); //But this is set 0_o?
    synchronized (session) {
        SocietyPeer.storeAddress(idSociety, ca);
    }
    addAddressesInSession(session, idSociety);
    form.reset(mapping, request);
}

ContactAddress class

package fr.model.society;

import fr.model.component.Address;

public class ContactAddress {

    private Long idContactAddress;

    private Address address;
    private Boolean invoiceAddress = false;

    private Society society;

    public Long getIdContactAddress() {
        return idContactAddress;
    }

    public void setIdContactAddress(Long id) {
        this.idContactAddress = id;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public void setInvoiceAddress(Boolean invoiceAddress) {
        this.invoiceAddress = invoiceAddress;
    }

    public Boolean getInvoiceAddress() {
        return invoiceAddress;
    }

    /**
     * **************** METHODES MAPPING *****************
     */
    public Society getSociety() {
        return society;
    }

    public void setSociety(Society society) {
        this.society = society;
    }

    public String toString() {
        return getAddress().toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof ContactAddress)) {
            return false;
        }
        ContactAddress ca = (ContactAddress) o;
        return address.equals(ca.getAddress()) && (getSociety().equals(ca.getSociety()));
    }

    public int hashCode() {
        return ((getIdContactAddress() == null) ? 0 : getIdContactAddress().hashCode())
                ^ address.hashCode()
                ^ ((getSociety() == null) ? 0 : getSociety().hashCode());
    }
}

Edit: Essentially I'm trying to set the invoiceAddress boolean variable and for all intents and purposes I can't at the moment. Nothing is printed in the console for java.lang.System.out.println("invoiceAddresss: " + caf.getInvoiceAddress()); I also tried passing it through a temp boolean variable and that variable isn't picked up in the debugger at all.


Solution

  • I loaded the project in Netbeans and this issue seems to be with eclipse and the Tomcat server. Must not be updating the Warfile despite re-building.