That worked, thanks. I'll update the javadocs, too.

On 20 June 2016 at 09:01, Greg Thomas <greg.d.tho...@gmail.com> wrote:

> Ah, yes. It seems the javadocs are wrong :( They pre-date the
> introduction of the helper class
>
> A better (i.e. working!) example is at
> https://logging.apache.org/log4j/2.x/manual/thread-context.html
>
> @Test
> public void name() throws Exception {
>
>   try (final CloseableThreadContext.Instance ctc =
> CloseableThreadContext.put("key", "value")) {
>
>   }
> }
>
> On 20 June 2016 at 14:57, Matt Sicker <boa...@gmail.com> wrote:
> > I tried doing it like in the javadocs and get a compilation error:
> >
> > @Test
> > public void name() throws Exception {
> > try (CloseableThreadContext.put("key", "value")) {
> > }
> > }
> >
> > List of errors:
> >
> > RequestIdFilterTest.java:12: error: <identifier> expected
> >                 try (CloseableThreadContext.put("key", "value")) {
> >                                                ^
> > RequestIdFilterTest.java:12: error: ')' expected
> >                 try (CloseableThreadContext.put("key", "value")) {
> >                                                 ^
> > RequestIdFilterTest.java:12: error: '{' expected
> >                 try (CloseableThreadContext.put("key", "value")) {
> >                                                      ^
> > RequestIdFilterTest.java:12: error: not a statement
> >                 try (CloseableThreadContext.put("key", "value")) {
> >                                                        ^
> > RequestIdFilterTest.java:12: error: ';' expected
> >                 try (CloseableThreadContext.put("key", "value")) {
> >                                                               ^
> > RequestIdFilterTest.java:17: error: reached end of file while parsing
> > }
> >  ^
> >
> > Am I doing something wrong here?
> >
> > --
> > Matt Sicker <boa...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
Matt Sicker <boa...@gmail.com>

Reply via email to