Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException in dry-run generation #1095

Closed
pierre opened this issue Feb 11, 2019 · 1 comment
Closed

IllegalStateException in dry-run generation #1095

pierre opened this issue Feb 11, 2019 · 1 comment

Comments

@pierre
Copy link
Member

pierre commented Feb 11, 2019

Scenario: trigger dry run invoice generation with a target date that is after the subscription (in-arrear usage) cancellation date.

java.lang.IllegalStateException: null
	at com.google.common.base.Preconditions.checkState(Preconditions.java:491)
	at org.killbill.billing.invoice.usage.RawUsageOptimizer.getOptimizedRawUsageStartDate(RawUsageOptimizer.java:124)
	at org.killbill.billing.invoice.usage.RawUsageOptimizer.getInArrearUsage(RawUsageOptimizer.java:75)
	at org.killbill.billing.invoice.generator.UsageInvoiceItemGenerator.generateItems(UsageInvoiceItemGenerator.java:117)
	at org.killbill.billing.invoice.generator.DefaultInvoiceGenerator.generateInvoice(DefaultInvoiceGenerator.java:98)
	at org.killbill.billing.invoice.InvoiceDispatcher.generateKillBillInvoice(InvoiceDispatcher.java:667)
	at org.killbill.billing.invoice.InvoiceDispatcher.processAccountWithLockAndInputTargetDate(InvoiceDispatcher.java:556)
	at org.killbill.billing.invoice.InvoiceDispatcher.processDryRun_TARGET_DATE_Invoice(InvoiceDispatcher.java:490)
	at org.killbill.billing.invoice.InvoiceDispatcher.processAccountWithLock(InvoiceDispatcher.java:390)
	at org.killbill.billing.invoice.InvoiceDispatcher.processAccount(InvoiceDispatcher.java:306)
@pierre
Copy link
Member Author

pierre commented Apr 22, 2019

Not reproducible.

@pierre pierre closed this as completed Apr 22, 2019
wwjbatista added a commit to wwjbatista/killbill that referenced this issue May 21, 2020
* payment: janitor: remove duplicated code from IncompletePaymentTransactionTask

This is part of a series of patches consolidating IncompletePaymentAttemptTask
and IncompletePaymentTransactionTask to fix killbill#1061.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: janitor: consolidate on-the-fly Janitor codepaths

This is part of a series of patches consolidating IncompletePaymentAttemptTask
and IncompletePaymentTransactionTask to fix killbill#1061.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Fix typo in comment

* invoice: Initial work to prune repaired items outside of tree logic. See killbill#1205

Pruning items outside of tree logic makes the code more robust because we can handle cases
that don't fit in the tree of interval. However in order to make this change, it is desirable
to adopt a consitent approach on how we handle full item adjustement -- see proposal doc.

* payment: janitor: remoev shared state between Janitor tasks

This is part of a series of patches consolidating IncompletePaymentAttemptTask
and IncompletePaymentTransactionTask to fix killbill#1061.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: janitor: fix for killbill#1061

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: change processedAmount computation in fixPaymentTransactionState

When going through the AdminPaymentApi, if we don't have plugin details
(e.g. when going through JAX-RS), assume processedAmount is the full amount
in case of success (and 0 in case of failures).

This ensures that the invoice balance will be updated after fixing the state
manually.

See killbill#1061 (comment)

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* invoice: Add required code to ensure that full-item adjustment old data is correctly handled by the new logic.

After cleaning up/simplifying  invoice code, we have to re-introduce some logic to handle old behavior
but the aim is that such code should be removed after we find a way to not repair too old data.

* payment: integrate Janitor with payment retries

The Janitor itself is always invoked, regardless if the payment
comes from an API call or not.

Retries are now however only triggered when that payment was not
triggered by an API call.

This fixes killbill#880.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* beatrix: Add new test case to verify invoice behavior on full item adj by parts

* beatrix: Port test TestIntegrationInvoiceWithRepairLogic#testRepairWithFullItemAdjustmentInParts to new invoice behavior where we generate -bash REPAIR items

* util: fix large table detection in Pagination queries

Instead of running the search query, search the full table
(regardless of search, tenant, etc.).

This fixes killbill#1218.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* server: support for Async

Set async-supported in all our filters so that things like
SSE are supported out of the box.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* junction, invoice: Initial attempt to keep serialized (encoded) billing events. See killbill#1204

* junction: Fix NPE in BillingEventSetJson

* .circleci: fix integration tests on for 0.21.x branches

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* circleci: fix -SNAPSHOT detection

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* usage: Add UsagePluginApi#getUsageForSubscription. See killbill#1214

* invoice: Add support for new table invoice_billing_events

* invoice: Undo billing event extensions for InvoiceInternalEvent and plug new table invoice_billing_events. See killbill#1204

* invoice: Rename invoice_billing_events column nz_billing_events -> lz_billing_events. See killbill#1204

* invoice: Prevent insertion of null entries into invoice_billing_events table. See killbill#1204

* util: Update ddl-postgresql to remap blob type to bytea. See killbill#1204

* Update latest parent pom.xml

* Minor CR for 1ebeb7c

* events: add missing toString methods

Events are logged by BeatrixListener, so having a meaningful
toString is useful.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* bin: add flyway-migrations script

Useful utility to debug corrupted migrations locally.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* junction, invoice: CR integration for 7b3e42d. See killbill#1204

Move billing events serialization into invoie DAO
Replace LZF encoding with Snappy
Rename table field lz_billing_events -> billing_events
Pass BillingEventSet instead of row bytes to interfaces

* server: make sure to clear the userToken from the MDC context

The userToken wasn't cleaned-up, so it was shared across requests.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* subscription: Prevent multiple future cancellations. See killbill#1207

* invoice: fix NPE in DefaultInvoiceDao

In case a duplicate transaction external key was used, invoice would
throw a NPE in the priorCall.

This fixes killbill#1230.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: perform AUTO_PAY_OFF check early when paying invoices

This fixes killbill#812.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* beatrix: fix typo in test name

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: remove payment_method_id from invoice_payment_control_plugin_auto_pay_off

This wasn't needed and lets us support AUTO_PAY_OFF accounts without a
default payment method.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* invoice: Add NodeInterval tests and tighten preconditions.

* subscription: Modify comment in DefaultSubscriptionBaseApiService as suggested in CR. See killbill#1207

* Remove explicit version for snappy-java by using latest released oss pom.xml

* jaxrs: support for callCompletion with future subscriptions

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: always run callCompletion in tests

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: fix callCompletion timeout with AUTO_INVOICING_OFF

This fixes killbill#1193.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: support callCompletion with AUTO_PAY_OFF

See killbill#1193.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: ignore unknown events in callCompletion

This fixes killbill#1211.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: support callCompletion with AUTO_INVOICING_DRAFT

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: fix callCompletion on change and cancel

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* server: fix test timing issues

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* invoice: prettify InvoiceItemBase#toString

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* invoice: Initial implementation to deal with overlapping invoice items inside our tree

* jaxrs: only fetch tags when callCompletion=true

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: fix callCompletion corner case when reference time is in the future

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* pom.xml: updates for release 0.20.13

See https://github.com/killbill/killbill/releases/tag/killbill-0.20.13

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.20.13

* [maven-release-plugin] prepare for next development iteration

* pom.xml: updates for release 0.21.5

See https://github.com/killbill/killbill/releases/tag/killbill-0.21.5

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.21.5

* [maven-release-plugin] prepare for next development iteration

* beatrix: Add invoice plugin tax scenario for adjustments

* entitlement: subscription: add error message to SUB_CREATE_INVALID_ENTITLEMENT_SPECIFIER

This fixes killbill#1201.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: fix PluginResource implementation

Make sure we support plugins paths including "plugins" (e.g. /plugins/killbill-kpm/plugins).

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Update parent pom.xml

* beatrix: Fixed test regression introduced in https://github.com/killbill/killbill-platform/pull/52/files#diff-9776f78cb61f7c7b71e1edab26984b5dR31

* util: ensure getTenantRecordIdUnsafe returns a non-null tenantRecordId

tenantRecordId should never be null: add some validation in case
a plugin attempts to call the TenantUserApi on an invalid tenantId for instance.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* invoice: targetDate adjustment should be limited to invoices with RECURRING or USAGE items. See killbill#1241

* jaxrs: Fix CatalogApi#getCatalogXml to take a DateTime. See killbill#1208

* pom.xml: updates for release 0.20.14

https://github.com/killbill/killbill/releases/tag/killbill-0.20.14
Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.20.14

* [maven-release-plugin] prepare for next development iteration

* Update TestIntegrationInvoice.java

Fix wrong comment

* invoice, jaxrs: Harmonize InvoiceUserApi#getUnpaidInvoicesByAccountId and InvoiceUserApi#getInvoicesByAccount to both take a startDate and upToDate Argument. See killbill#1134

* beatrix, invoice: Fix compilation issues from 2dfd222

* iinvoice: Change semantics of 'upToDate' in InvoiceUserApi#getUnpaidInvoicesByAccountId and InvoiceUserApi#getInvoicesByAccount apis to both use it as an inclusive date. See killbill#1134

Our current overdue system relies on this convention to work correctly and so the code change introduced in 2dfd222 triggered a regression.

* profiles: Update java client version

* pom.xml: updates for release 0.21.6

See https://github.com/killbill/killbill/releases/tag/killbill-0.21.6

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.21.6

* [maven-release-plugin] prepare for next development iteration

* subscription: Fix computation of cancelation effective date to use the latest PHASE boundary as a minimum. See killbill#125

* subscription: Tigthen fix introduced in 037af23 for cases of pending subscription. See killbill#1215

* invoice: Relax the code to allow for too much invoice item adjustments.

Write tests scenario to verify the Preconditions we added for bad data are correctly working, and also
verify that in the case of too much adjustments, doing an extra invoice run will work (and not create additional bad state).

* invoice: Fix warn log in RawUsageOptimizer. See killbill#1095

* invoice: CR integration for PR#1247. Minor tweaks in logging

* pom.xml: updates for release 0.21.7

See https://github.com/killbill/killbill/releases/tag/killbill-0.21.7

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.21.7

* [maven-release-plugin] prepare for next development iteration

* config: reduce default number of threads

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: code review integration

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Update parent oss pom.xml

* invoice: Fix invoice regression when upgrading from 0.21.x -> 0.22. See killbill#1251

* invoice: Change default logic when fetching audit logs to support migration from 0.20.x ->  0.22.x. See killbill#1252

* invoice: Remove optimization to close iterator early to support data created without history in 0.20.x. See killbill#1252

* invoice: Fix invoice regression when upgrading from 0.21.x -> 0.22. See killbill#1251

* invoice: Fix invoice regression when upgrading from 0.21.x -> 0.22. See killbill#1251

* invoice, beatrix: Add regression test for 0_20 to 0_22. See killbill#1254

* invoice: Minor comment edits. See killbill#1254

* beatrix, invoice: Add test cases to verify upgrade scenario. See killbill#1251

This tests a scenario where we move from monthly -> annual with a pause in the middle.
The test partially fails as it should regenerate nothing and instead regenerates 2 canceling items (net is $0).

* beatrix. Minor comment edit.

* pom.xml: updates for release 0.21.8

See https://github.com/killbill/killbill/releases/tag/killbill-0.21.8

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.21.8

* [maven-release-plugin] prepare for next development iteration

* Fix invoice regression introduced in beca83b.

The change introduced in killbill@beca83b#diff-6bbd5e696930ee20c12f24087244c833R234
is actually correct, i.e the recurring billing associated with an event marking cancelation or pause should be set to `NO_BILLING_PERIOD`.

However, our invoicing code contains another bug where we keep adding future notifications for canceled subscriptions. Prior this change,
this was not visible as the notification was set in the future but with the change from commit beca83b, the notification becomes in the past
and what was previously an unused future notification now leads to infinite loops.

The fix is to remove future notifications when there is nothing to invoice in the future.

* util: remove DefaultNodeCommandMetadata

Another version is present in killbill-api and can
conflict in plugins (same package).

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* beatrix: Refactor tests to have in-arrear first class citizens tests.

* beatrix: Add scenario for pause-resume with in-arrear subscriptions

* beatrix: Harden pause-resume tests

* invoice: Add unit tests for FixedAndRecurringInvoiceItemGenerator (IN_ADVANCE & IN_ARREAR)

* pom.xml: update to killbill-oss-parent 0.143.44

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* circleci: update config

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.21.9

* [maven-release-plugin] prepare for next development iteration

* jaxrs: pass kbVersion to KPM bundle

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.22.0

* [maven-release-plugin] prepare for next development iteration

* util: define longtext in the PostgreSQL bridge

While it is not used in Kill Bill core, longtext is used in plugins
(e.g. Stripe).

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* pom.xml: update to killbill-oss-parent 0.143.50

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.22.1

* [maven-release-plugin] prepare for next development iteration

* payment: Fix incorrect call to control plugins from janitor during a GET where there was no transaction status change. See killbill#1264

* payment: Fix broken TestJanitor afterMethod

* payment: CR for 14f2cf0. See killbill#1264

* payment. Small cosmetic changes. See killbill#1264

* catalog: Plug JAXB catalog validation when adding a simple plan. See killbill#1267

* pom.xml: updates for release 0.22.2

See https://github.com/killbill/killbill/releases/tag/killbill-0.22.2

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.22.2

* [maven-release-plugin] prepare for next development iteration

* Create FUNDING.yml

* invoice, payment: Add paymentAttemptId into the INVOICE_PAYMENT_SUCCESS json (InvoicePaymentMetadata)

* payment: Fix use of wrong ID in InvoicePaymentControlPluginApi

* Update oss parent pom.xml

* payment: Fix ordering for control plugins for invoice payment to have first __INVOICE_PAYMENT_CONTROL_PLUGIN__. See killbill#1276

* payment: Fix issue with control plugins insertion list introduced in 3d411ec. See killbill#1276

* payment: Fix reported issue where control plugin are called with an incorrect context

The context contained the wrong `pluginName` (te one from previous plugin invoked), and also
provides info about processed currency and amount which is inacurate.

* profiles: Fix flakiness in tests by hardcoding the bad planId

* invoice: park accounts when recorded usage data isn't defined in the catalog

This fixes killbill#1275.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* jaxrs: don't pull the invoice unnecessarily when retrieving tags

This fixes killbill#1273.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* circleci: use backport-0.20.x branch for integration tests

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: Revert passing null processed amount/currency in priorCall (see e027ff6)

* pom.xml: updates for release 0.22.3

See https://github.com/killbill/killbill/releases/tag/killbill-0.22.3

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.22.3

* [maven-release-plugin] prepare for next development iteration

* invoice: code review integration

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.20.15

* [maven-release-plugin] prepare for next development iteration

* beatrix: add new test suggested in the code review

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: fix Janitor flow for control plugins

Backport fix of killbill#1264.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* invoice: ignore tracking ids for unknown unit types

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* payment: always populate payment attempt amount and currency

The amount and currency used to be set before the state machine runs.
If the amount was set by a control plugin (priorCall), the amount could
be NULL. This was inconsistent and confusing.

This fixes killbill#1281.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.20.16

* [maven-release-plugin] prepare for next development iteration

* [maven-release-plugin] prepare release killbill-0.22.4

* [maven-release-plugin] prepare for next development iteration

* Update FUNDING.yml

* shiro: add mechanism to bypass authentication from plugins

When org.killbill.security.skipAuthForPlugins=true, plugins calling
Kill Bill APIs with a context where CallOrigin.INTERNAL and UserType.ADMIN
will not need to be authenticated.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Update parent pom,xml

* pom.xml: updates for release 0.22.5

See https://github.com/killbill/killbill/releases/tag/killbill-0.22.5

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.22.5

* [maven-release-plugin] prepare for next development iteration

* jaxrs: fix NPE in getPaymentsForInvoice

Handle the case of invoice payments with a NULL payment id (i.e. when
the payment is aborted by a payment control plugin). These won't
be returned by the API.

For testing, I had to add a new (undocumented) query parameter to
the createInstantPayment API, in order to add an additional payment
control plugin to the chain.

This fixes killbill#1288.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Update README.md

* Update parent pom.xml (share killbill-commons from master)

* pom.xml: updates for release 0.20.17

Port killbill-commons (queue) from master

Signed-off-by: Kill Bill core team <contact@killbill.io>

* Fix maven dependency:check errors

E.g:
[ERROR] Found a problem with the dependency org.objenesis:objenesis
  Resolved version is 2.1
  Version 2.1 was expected by artifact: org.awaitility:awaitility
  Version 2.5.1 was expected by artifacts: org.kill-bill.billing:killbill-catalog, org.kill-bill.billing:killbill-catalog:test-jar, org.kill-bill.billing:killbill-util, org.kill-bill.billing:killbill-util:test-jar

* Fix NEWS (incorrect entry)

* pom.xml: updates for release 0.20.17

https://github.com/killbill/killbill/releases/tag/killbill-0.20.17
Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.20.17

* [maven-release-plugin] prepare for next development iteration

* Update parent pom.xml (minor compilation fixes in killbill-commons for 0.20.17)

* invoice: clarify behavior for skipping overlapping usage items

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Update killbill-server-update-list.properties

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.22.6

* [maven-release-plugin] prepare for next development iteration

* Integrate with new START_BUS lifeycle event.

The main change is in killbill/killbill-commons@a4a4024 and killbill/killbill-platform@32552b8

* pom.xml: update to new MySQL embeddeddb

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* Update parent pom.xml

* pom.xml: updates for release 0.22.7

See https://github.com/killbill/killbill/releases/tag/killbill-0.22.7

Signed-off-by: Kill Bill core team <contact@killbill.io>

* [maven-release-plugin] prepare release killbill-0.22.7

* [maven-release-plugin] prepare for next development iteration

* Update README.md

* invoice: only COMMITTED invoices should update the CTD

This fixes killbill#1296.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* server: fix flaky test following CTD logic change

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* pom.xml: prepare 0.22.8 release

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>

* [maven-release-plugin] prepare release killbill-0.22.8

* [maven-release-plugin] prepare for next development iteration

Co-authored-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Co-authored-by: Stéphane Brossier <stephane@kill-bill.org>
Co-authored-by: stephane brossier <sbrossier@groupon.com>
Co-authored-by: Kill Bill core team <contact@killbill.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant