--- old/src/solaris/native/sun/awt/awt_GraphicsEnv.c 2012-12-29 00:29:54.148266000 +0400 +++ new/src/solaris/native/sun/awt/awt_GraphicsEnv.c 2012-12-29 00:29:53.660168400 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -905,13 +905,18 @@ static jint canUseShmExt = UNSET_MITSHM; static jint canUseShmExtPixmaps = UNSET_MITSHM; static jboolean xshmAttachFailed = JNI_FALSE; +static int j2dxErrHandlerCallsCount = 0; int J2DXErrHandler(Display *display, XErrorEvent *xerr) { int ret = 0; if (xerr->minor_code == X_ShmAttach) { xshmAttachFailed = JNI_TRUE; } else { - ret = (*xerror_saved_handler)(display, xerr); + // Verify that this handler is not called twice for the same error. + if (++j2dxErrHandlerCallsCount < 2) { + ret = (*xerror_saved_handler)(display, xerr); + } + j2dxErrHandlerCallsCount--; } return ret; }