Return-Path: X-Original-To: apmail-jmeter-user-archive@www.apache.org Delivered-To: apmail-jmeter-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5A19E10E4A for ; Sat, 21 Dec 2013 03:23:12 +0000 (UTC) Received: (qmail 29790 invoked by uid 500); 21 Dec 2013 03:23:08 -0000 Delivered-To: apmail-jmeter-user-archive@jmeter.apache.org Received: (qmail 29630 invoked by uid 500); 21 Dec 2013 03:23:05 -0000 Mailing-List: contact user-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JMeter Users List" Delivered-To: mailing list user@jmeter.apache.org Received: (qmail 29621 invoked by uid 99); 21 Dec 2013 03:23:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Dec 2013 03:23:03 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.86.89.61] (HELO elasmtp-galgo.atl.sa.earthlink.net) (209.86.89.61) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Dec 2013 03:22:56 +0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=mindspring.com; b=i+VUy3fSVhcdh4coQHsAO8jj4hL/nXyB4nCm1YU092cmsT+pCrW29kcev99Mr8zO; h=X-Google-DKIM-Signature:X-Received:MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject:To:Content-Type:X-ELNK-Trace:X-Originating-IP; Received: from [209.85.128.46] (helo=mail-qe0-f46.google.com) by elasmtp-galgo.atl.sa.earthlink.net with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.67) (envelope-from ) id 1VuD98-0006CD-RU for user@jmeter.apache.org; Fri, 20 Dec 2013 22:22:34 -0500 Received: by mail-qe0-f46.google.com with SMTP id a11so3193603qen.19 for ; Fri, 20 Dec 2013 19:22:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=1aVLYIYkzwCsbtKI/aOBvWJVF3+tSnJWeQZ/MgJR/Bc=; b=aV8LcYVKijfYW8mkR+v34nVkNFmmXTTnHu6+Bxs+t3CSYuCj3NHWhujDYrd3Y5vjdp dJVLZmH0W5EmpkQ/hNOAkysgpzZQfcQBFyGHhpWI6w4JLfPe5Qq4Ux7rkJsqwjw7LVJW 3cxM2AbURX/WqJmoJ2P/r9jmaLY/yHuh5qegFGchETvcu845if/1OB0hg0YpHn0IrGQJ PFCedGs4bKbsJqu1Xt41nkXypGtw0qaMT7Nvi6U8xhGcu34sUP6XLVnWi5M5daWozfVU 1Io7SJhfSdRDuA0U+mhD8zRGHvIigI0ZCYhMyg+dXKsBoRDdJKMjMj62OxrirnQW5ULj 2s0g== X-Received: by 10.224.1.198 with SMTP id 6mr20573639qag.19.1387596153965; Fri, 20 Dec 2013 19:22:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.87.198 with HTTP; Fri, 20 Dec 2013 19:21:53 -0800 (PST) In-Reply-To: References: From: RL Date: Fri, 20 Dec 2013 19:21:53 -0800 Message-ID: Subject: Re: Using Beanshell Assertion to test a JSON value To: JMeter Users List Content-Type: multipart/alternative; boundary=001a11c2e7d6d9539604ee02e73f X-ELNK-Trace: 9f1192855f2a3883f402879cecb40bd596d49a9b4c7fb3e283d18ab8bdb3f590dda7b9c5dad5a163350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 209.85.128.46 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2e7d6d9539604ee02e73f Content-Type: text/plain; charset=ISO-8859-1 Hm. I did a kludgy workaround that seems to work. I wonder if it's worth reporting as a bug that vars.get crashes if the specified variable doesn't exist. Surely that would have been well known by now? My kludgy solution was to predefine blobValue as -1, then check to see if it's still -1 after the JSON Path Extraction. Since this particular parameter should never have a value of -1, if it still does, that means that the JSON Path Extraction failed because its value is really null. If the extraction succeeds, it would have a different value. Whew... Thanks for the help and comments. On Fri, Dec 20, 2013 at 7:06 PM, RL wrote: > > String blobValue = vars.get("blobValue"); > >> >> what does vars.get() return if the variable does not exist? >> >> > Right. That's what's causing the crash. If I create blobValue explicitly > beforehand the Beanshell Assertion works. > > So the question more narrowly defined is: how can one test for the > existence of a variable before doing a vars.get, since vars.get crashes if > the specified variable doesn't exist? > > > --001a11c2e7d6d9539604ee02e73f--