Skip to content

swap NOT_IMPLEMENTED for NOT_REACHED where appropriate#765

Merged
mattklein123 merged 1 commit intomasterfrom
not_reached
Apr 14, 2017
Merged

swap NOT_IMPLEMENTED for NOT_REACHED where appropriate#765
mattklein123 merged 1 commit intomasterfrom
not_reached

Conversation

@mattklein123
Copy link
Copy Markdown
Member

Fixes #590

@mattklein123
Copy link
Copy Markdown
Member Author

@lyft/network-team

@PiotrSikora
Copy link
Copy Markdown
Contributor

You could move the NOT_REACHED into switch statement in most of the cases, i.e.:

switch (...) {
...
default:
  NOT_REACHED
}

Also, is there any reason why NOT_REACHED is implemented as log entry instead of EnvoyException?

@htuch
Copy link
Copy Markdown
Member

htuch commented Apr 14, 2017

I think the idea is that the compiler was too dumb to figure out all cases had been covered, but I'm still surprised this is the case. I wonder if we're missing some flags.

@mattklein123
Copy link
Copy Markdown
Member Author

You could move the NOT_REACHED into switch statement in most of the cases

Yes, per @htuch the compiler is too stupid to realize that all cases are covered and the function will always return. It's better to not have a default in a switch statement if not necessary because the compiler will error that not all cases are covered. This is why I didn't add default.

Also, is there any reason why NOT_REACHED is implemented as log entry instead of EnvoyException

It logs and then calls abort(). This is better than an exception because it guarantees immediate core dump where an exception might be caught.

@PiotrSikora lmk if these explanations satisfy you.

@PiotrSikora
Copy link
Copy Markdown
Contributor

It logs and then calls abort(). This is better than an exception because it guarantees immediate core dump where an exception might be caught.

@mattklein123 That makes sense, thanks!

@mattklein123 mattklein123 merged commit acc5164 into master Apr 14, 2017
@mattklein123 mattklein123 deleted the not_reached branch April 14, 2017 21:03
mathetake added a commit that referenced this pull request Mar 3, 2026
**Commit Message**

Previously, the controller didn't fallback to /v1 version for OpenAI
schema since #706 which starts utilizing schema.version field. The field
was previously non nil hence in many cases, it was set to empty, and
that caused the backward incompatibility. This fixes it by defaulting to
v1 when the field is set but empty string.

**Related Issues/PRs (if applicable)**

Follow up on #706

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants