[jboss-jira] [JBoss JIRA] (LOGTOOL-78) Wrong exception constructor is matched

David Lloyd (JIRA) jira-events at lists.jboss.org
Mon Nov 18 11:19:05 EST 2013


David Lloyd created LOGTOOL-78:
----------------------------------

             Summary: Wrong exception constructor is matched
                 Key: LOGTOOL-78
                 URL: https://issues.jboss.org/browse/LOGTOOL-78
             Project: Log Tool
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 1.2.0.Beta1
            Reporter: David Lloyd
            Assignee: James Perkins


The following exception class:

{code}
/*
 * JBoss, Home of Professional Open Source
 *
 * Copyright 2013 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.xnio.http;

import java.io.IOException;

/**
 * An extension of {@link IOException} used to convey that a connection has failed as a redirect has been encountered.
 *
 * @author <a href="mailto:darran.lofthouse at jboss.com">Darran Lofthouse</a>
 */
public class RedirectException extends IOException {

    private final int statusCode;
    private final String location;

    /**
     * Constructs a new {@code RedirectException} instance.  The message is left blank ({@code null}), and no cause is
     * specified.
     *
     * @param statusCode the status code
     * @param location the redirection location, if any
     */
    public RedirectException(final int statusCode, final String location) {
        this.statusCode = statusCode;
        this.location = location;
    }

    /**
     * Constructs a new {@code RedirectException} instance with an initial message.  No cause is specified.
     *
     * @param msg the message
     * @param statusCode the status code
     * @param location the redirection location, if any
     */
    public RedirectException(final String msg, final int statusCode, final String location) {
        super(msg);
        this.statusCode = statusCode;
        this.location = location;
    }

    /**
     * Constructs a new {@code RedirectException} instance with an initial cause.  If a non-{@code null} cause is
     * specified, its message is used to initialize the message of this {@code RedirectException}; otherwise the message
     * is left blank ({@code null}).
     *
     * @param cause the cause
     * @param statusCode the status code
     * @param location the redirection location, if any
     */
    public RedirectException(final Throwable cause, final int statusCode, final String location) {
        super(cause);
        this.statusCode = statusCode;
        this.location = location;
    }

    /**
     * Constructs a new {@code RedirectException} instance with an initial message and cause.
     *
     * @param msg the message
     * @param cause the cause
     * @param statusCode the status code
     * @param location the redirection location, if any
     */
    public RedirectException(final String msg, final Throwable cause, final int statusCode, final String location) {
        super(msg, cause);
        this.statusCode = statusCode;
        this.location = location;
    }

    /**
     * Get the HTTP status code.  This is the reason for the redirect.
     *
     * @return the status code
     */
    public int getStatusCode() {
        return statusCode;
    }

    /**
     * Get the redirection target location.
     *
     * @return the redirection target location
     */
    public String getLocation() {
        return location;
    }

}
{code}

with this declaration:

{code}
    @Message(id = 816, value = "Redirect encountered establishing connection")
    RedirectException redirect(@Param int responseCode, @Param String location);
{code}

results in this generated code:

{code}
    public final org.xnio.http.RedirectException redirect(final int responseCode, final java.lang.String location) {
        org.xnio.http.RedirectException result = new org.xnio.http.RedirectException(responseCode, java.lang.String.format(redirect$str()));
        java.lang.StackTraceElement[] st = result.getStackTrace();
        result.setStackTrace(java.util.Arrays.copyOfRange(st, 1, st.length));
        return result;
    }
{code}

Which doesn't make any sense.  There is clearly a message so the rule should be to match an exception with a message parameter followed by {{@Param}} annotations.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list