Hi Tomek,

Before we open up the API more by using protected or public methods, I'd
like to fix what we can in the code.

Can you take a look at trunk and
org.apache.logging.log4j.core.net.UDPSocketServerTest and the tests that
are @Ignore'd there?

Thank you,
Gary


On Mon, May 13, 2013 at 8:07 AM, Tomek Kaczynski
<[email protected]>wrote:

> Hi, All
>
>    Because of a bug already reported by me 
> (LOG4J2-246<https://issues.apache.org/jira/browse/LOG4J2-246>),
> I had to write an Appender containing a fix/workaround.
>
>  Obvious approach for me would be inherittance from
> AbstractOutputStreamAppender and overriding method append. However I
> couldn't do that because:
>
> manager.write(bytes); and
> manager.flush(); are package visible only + few other visibility issues.
>
> So I would suggest to use more protected visibility than package as well
> as 'template method' pattern, especially in classes like
> AbstractOutputStreamAppender.
>
>
> In order to finalize my story I have to say that the final solution was to
> put
> a copied AbstractOutputStreamAppender and new Appender in namespace
> org.apache..... which is definitely not nice.
>
>
>
> So, can you please consider making changes that would make lives of
> extensions writers a little bit easier ?
>
>
> Regards,
> Tomek
>
> -------------------------------------------------
>     @Override
>     public void append(final LogEvent event) {
>
>         final byte[] bytes = getLayout().toByteArray(event);
>         boolean failedOnSize = false;
>
>         readLock.lock();
>         try {
>
>             if (bytes.length > 0) {
>                 if (bytes.length <= udpSizeLimit) {
>                     manager.write(bytes);
>                     if (this.immediateFlush || event.isEndOfBatch()) {
>                         manager.flush();
>                     }
>                 } else {
>                     failedOnSize = true;
>                 }
>             }
>         } catch (final AppenderRuntimeException ex) {
>             error("Unable to write to stream " + manager.getName() + " for
> appender " + getName());
>             throw ex;
>         } finally {
>             readLock.unlock();
>         }
>
>         if (failedOnSize) {
>             handleFailedSize(event, bytes);
>         }
>     }----------------------------------------------
>



-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to