Skip to content

Fix bugs related to zero components in sequence#1767

Closed
ioana-blue wants to merge 4 commits intoapache:masterfrom
ioana-blue:ioana-fix-size
Closed

Fix bugs related to zero components in sequence#1767
ioana-blue wants to merge 4 commits intoapache:masterfrom
ioana-blue:ioana-fix-size

Conversation

@ioana-blue
Copy link
Contributor

Don't allow creation of sequences with no components (+ test). Guard size calculation just in case.

@ioana-blue
Copy link
Contributor Author

Fixes #1760


protected[core] case class SequenceExec(components: Vector[FullyQualifiedEntityName]) extends Exec(Exec.SEQUENCE) {
override def size = components.map(c => c.size).reduce(_ + _)
override def size = if (components.size > 0) components.map(c => c.size).reduce(_ + _) else (0 B)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

components.map(c => c.size).reduceOption(_ + _).getOrElse(0.B)

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do we even need size calculation on Sequences? Isn't the "size" of the list bound by its count anyway? Could we always return 0 byte?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know about reduceOption. gracias.

@ioana-blue
Copy link
Contributor Author

PG3 209

@ioana-blue
Copy link
Contributor Author

this is ready to merge as far as I'm concerned @markusthoemmes the ball is in your court

@rabbah
Copy link
Member

rabbah commented Jan 27, 2017

@ioana-blue if this is pg approved, please add corresponding label.

@ioana-blue
Copy link
Contributor Author

@rabbah can't add label, I'm just a contributor :)

@ioana-blue
Copy link
Contributor Author

I can't do any assignments on the right hand side of this window... to be more precise

@rabbah rabbah added pgapproved Pipeline has approved this change. review Review for this PR has been requested and yet needs to be done. labels Jan 27, 2017

private case class BlockingInvokeTimeout(activationId: ActivationId) extends TimeoutException
private case class TooManyActionsInSequence() extends RuntimeException
private case class NoComponentInSequence() extends RuntimeException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be illegal state exceptions instead of runtime exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debatable. IllegalStateException makes me think that I made a request at a bad time (bad state on the server side). these exception look more similar to IllegalArgumentException - I'm performing a request with arguments that don't fit the bill/contract.

I don't feel strongly about this, so I can change them. what's it gonna be? @rr @markusthoemmes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException is what I meant - thanks. That's appropriate. RuntimeExceptions don't fit these.

@ioana-blue
Copy link
Contributor Author

all done. anything else?

val content = WhiskActionPut(Some(Exec.sequence(Vector())))

// create an action sequence
Put(s"$collectionPath/${seqName.name}", content) ~> sealRoute(routes(creds)) ~> check {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also test on update (?overwrite=true).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test


protected[core] case class SequenceExec(components: Vector[FullyQualifiedEntityName]) extends Exec(Exec.SEQUENCE) {
override def size = components.map(c => c.size).reduce(_ + _)
override def size = components.map(c => c.size).reduceOption(_ + _) getOrElse (0 B)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markusthoemmes once we limit the length of the action names, i'm ok turning this into a no-op (return 0.B).

@ioana-blue
Copy link
Contributor Author

ioana-blue commented Feb 1, 2017

PG3 225 approved

@ioana-blue ioana-blue added ready and removed review Review for this PR has been requested and yet needs to be done. labels Feb 1, 2017
@rabbah
Copy link
Member

rabbah commented Feb 4, 2017

Merged as 5ace507.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pgapproved Pipeline has approved this change. ready sequences

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants